aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--manual/qpdf-manual.xml26
-rw-r--r--qpdf/qpdf.cc39
-rw-r--r--qpdf/qtest/qpdf.test10
-rw-r--r--qpdf/qtest/qpdf/minimal-rotated.pdfbin0 -> 811 bytes
5 files changed, 52 insertions, 27 deletions
diff --git a/ChangeLog b/ChangeLog
index 26cbd5fe..cdf8f266 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/manual/qpdf-manual.xml b/manual/qpdf-manual.xml
index 5287243e..3feb9fda 100644
--- a/manual/qpdf-manual.xml
+++ b/manual/qpdf-manual.xml
@@ -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>
diff --git a/qpdf/qpdf.cc b/qpdf/qpdf.cc
index bcc5927c..c5b0fd8e 100644
--- a/qpdf/qpdf.cc
+++ b/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,25 +1304,33 @@ static void parse_rotation_parameter(Options& o, std::string const& parameter)
if (colon > 0)
{
angle_str = parameter.substr(0, colon);
- if (angle_str.length() > 0)
- {
- char first = angle_str.at(0);
- if ((first == '+') || (first == '-'))
- {
- relative = ((first == '+') ? 1 : -1);
- angle_str = angle_str.substr(1);
- }
- else if (! QUtil::is_digit(angle_str.at(0)))
- {
- angle_str = "";
- }
- }
}
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);
+ if ((first == '+') || (first == '-'))
+ {
+ relative = ((first == '+') ? 1 : -1);
+ angle_str = angle_str.substr(1);
+ }
+ else if (! QUtil::is_digit(angle_str.at(0)))
+ {
+ angle_str = "";
+ }
+ }
+ if (range.empty())
+ {
+ range = "1-z";
+ }
bool range_valid = false;
try
{
diff --git a/qpdf/qtest/qpdf.test b/qpdf/qtest/qpdf.test
index 5f5b9612..2ba0ff5f 100644
--- a/qpdf/qtest/qpdf.test
+++ b/qpdf/qtest/qpdf.test
@@ -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 ---");
diff --git a/qpdf/qtest/qpdf/minimal-rotated.pdf b/qpdf/qtest/qpdf/minimal-rotated.pdf
new file mode 100644
index 00000000..b40724b1
--- /dev/null
+++ b/qpdf/qtest/qpdf/minimal-rotated.pdf
Binary files differ