mirror of
https://github.com/qpdf/qpdf.git
synced 2024-10-31 19:02:30 +00:00
Make page range optional in --rotate (fixes #211)
This commit is contained in:
parent
9d7eef7cc6
commit
84cd53f5af
@ -1,5 +1,9 @@
|
||||
2018-06-21 Jay Berkenbilt <ejb@ql.org>
|
||||
|
||||
* The --rotate option to qpdf no longer requires an explicit page
|
||||
range. You can now rotate all pages of a document with
|
||||
qpdf --rotate=angle in.pdf out.pdf. Fixes #211.
|
||||
|
||||
* Create examples/pdf-set-form-values.cc to illustrate use of
|
||||
interactive form helpers.
|
||||
|
||||
|
@ -412,22 +412,26 @@ make
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>--rotate=[+|-]angle:page-range</option></term>
|
||||
<term><option>--rotate=[+|-]angle[:page-range]</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Apply rotation to specified pages. The
|
||||
<option>page-range</option> portion of the option value has
|
||||
the same format as page ranges in <xref
|
||||
linkend="ref.page-selection"/>. The <option>angle</option>
|
||||
portion of the parameter may be either 90, 180, or 270. If
|
||||
preceded by <option>+</option> or <option>-</option>, the
|
||||
angle is added to or subtracted from the specified pages'
|
||||
original rotations. Otherwise the pages' rotations are set to
|
||||
the exact value. For example, the command <command>qpdf in.pdf
|
||||
out.pdf --rotate=+90:2,4,6 --rotate=180:7-8</command> would
|
||||
rotate pages 2, 4, and 6 90 degrees clockwise from their
|
||||
original rotation and force the rotation of pages 7 through 9
|
||||
to 180 degrees regardless of their original rotation.
|
||||
linkend="ref.page-selection"/>. If the page range is omitted,
|
||||
the rotation is applied to all pages. The
|
||||
<option>angle</option> portion of the parameter may be either
|
||||
90, 180, or 270. If preceded by <option>+</option> or
|
||||
<option>-</option>, the angle is added to or subtracted from
|
||||
the specified pages' original rotations. Otherwise the pages'
|
||||
rotations are set to the exact value. For example, the command
|
||||
<command>qpdf in.pdf out.pdf --rotate=+90:2,4,6
|
||||
--rotate=180:7-8</command> would rotate pages 2, 4, and 6 90
|
||||
degrees clockwise from their original rotation and force the
|
||||
rotation of pages 7 through 9 to 180 degrees regardless of
|
||||
their original rotation, and the command <command>qpdf in.pdf
|
||||
out.pdf --rotate=180</command> would rotate all pages by 180
|
||||
degrees.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
21
qpdf/qpdf.cc
21
qpdf/qpdf.cc
@ -241,8 +241,9 @@ Basic Options\n\
|
||||
--decrypt remove any encryption on the file\n\
|
||||
--password-is-hex-key treat primary password option as a hex-encoded key\n\
|
||||
--pages options -- select specific pages from one or more files\n\
|
||||
--rotate=[+|-]angle:page-range\n\
|
||||
rotate each specified page 90, 180, or 270 degrees\n\
|
||||
--rotate=[+|-]angle[:page-range]\n\
|
||||
rotate each specified page 90, 180, or 270 degrees;\n\
|
||||
rotate all pages if no page range is given\n\
|
||||
--split-pages=[n] write each output page to a separate file\n\
|
||||
\n\
|
||||
Note that you can use the @filename or @- syntax for any argument at any\n\
|
||||
@ -1303,6 +1304,16 @@ static void parse_rotation_parameter(Options& o, std::string const& parameter)
|
||||
if (colon > 0)
|
||||
{
|
||||
angle_str = parameter.substr(0, colon);
|
||||
}
|
||||
if (colon + 1 < parameter.length())
|
||||
{
|
||||
range = parameter.substr(colon + 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
angle_str = parameter;
|
||||
}
|
||||
if (angle_str.length() > 0)
|
||||
{
|
||||
char first = angle_str.at(0);
|
||||
@ -1316,11 +1327,9 @@ static void parse_rotation_parameter(Options& o, std::string const& parameter)
|
||||
angle_str = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (colon + 1 < parameter.length())
|
||||
if (range.empty())
|
||||
{
|
||||
range = parameter.substr(colon + 1);
|
||||
}
|
||||
range = "1-z";
|
||||
}
|
||||
bool range_valid = false;
|
||||
try
|
||||
|
@ -1124,7 +1124,7 @@ foreach my $d (@sp_cases)
|
||||
show_ntests();
|
||||
# ----------
|
||||
$td->notify("--- Rotate Pages ---");
|
||||
$n_tests += 2;
|
||||
$n_tests += 4;
|
||||
# Do absolute, positive, and negative on ranges that include
|
||||
# inherited and non-inherited.
|
||||
# Pages 11-15 inherit /Rotate 90
|
||||
@ -1141,6 +1141,14 @@ $td->runtest("check output",
|
||||
{$td->FILE => "a.pdf"},
|
||||
{$td->FILE => "rotated.pdf"});
|
||||
|
||||
$td->runtest("rotate all pages",
|
||||
{$td->COMMAND =>
|
||||
"qpdf --static-id --rotate=180 minimal.pdf a.pdf"},
|
||||
{$td->STRING => "", $td->EXIT_STATUS => 0});
|
||||
$td->runtest("check output",
|
||||
{$td->FILE => "a.pdf"},
|
||||
{$td->FILE => "minimal-rotated.pdf"});
|
||||
|
||||
show_ntests();
|
||||
# ----------
|
||||
$td->notify("--- Numeric range parsing tests ---");
|
||||
|
BIN
qpdf/qtest/qpdf/minimal-rotated.pdf
Normal file
BIN
qpdf/qtest/qpdf/minimal-rotated.pdf
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user