diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | manual/qpdf-manual.xml | 9 | ||||
-rw-r--r-- | qpdf/qpdf.cc | 14 | ||||
-rw-r--r-- | qpdf/qtest/qpdf.test | 14 |
4 files changed, 31 insertions, 12 deletions
@@ -1,3 +1,9 @@ +2019-01-12 Jay Berkenbilt <ejb@ql.org> + + * In --pages, allow "." as a replacement for the current input + file, making it possible to say "qpdf A.pdf --pages . 1-3 --" + instead of having to repeat the input filename. + 2019-01-10 Jay Berkenbilt <ejb@ql.org> * Add new configure option --enable-avoid-windows-handle, which diff --git a/manual/qpdf-manual.xml b/manual/qpdf-manual.xml index d30e8ea4..f7c528b7 100644 --- a/manual/qpdf-manual.xml +++ b/manual/qpdf-manual.xml @@ -956,6 +956,11 @@ make selection flags. </para> <para> + Starting with qpf 8.4, the special input file name + “<filename>.</filename>” can be used shortcut for the + primary input filename. + </para> + <para> For each file that pages should be taken from, specify the file, a password needed to open the file (if any), and a page range. The password needs to be given only once per file. If any of the @@ -1075,7 +1080,7 @@ make <filename>infile.pdf</filename> while preserving all metadata associated with that file, you could use - <programlisting><command>qpdf</command> <option>infile.pdf --pages infile.pdf 1-5 -- outfile.pdf</option> + <programlisting><command>qpdf</command> <option>infile.pdf --pages . 1-5 -- outfile.pdf</option> </programlisting> If you wanted pages 1 through 5 from <filename>infile.pdf</filename> but you wanted the rest of the @@ -1087,7 +1092,7 @@ make <filename>file1.pdf</filename> and pages 11–15 from <filename>file2.pdf</filename> in reverse, you would run - <programlisting><command>qpdf</command> <option>file1.pdf --pages file1.pdf 1-5 file2.pdf 15-11 -- outfile.pdf</option> + <programlisting><command>qpdf</command> <option>file1.pdf --pages file1.pdf 1-5 . 15-11 -- outfile.pdf</option> </programlisting> If, for some reason, you wanted to take the first page of an encrypted file called <filename>encrypted.pdf</filename> with diff --git a/qpdf/qpdf.cc b/qpdf/qpdf.cc index e7d9eab7..db3193d5 100644 --- a/qpdf/qpdf.cc +++ b/qpdf/qpdf.cc @@ -1092,7 +1092,8 @@ ArgParser::argHelp() << "password needs to be given only once per file. If any of the input\n" << "files are the same as the primary input file or the file used to copy\n" << "encryption parameters (if specified), you do not need to repeat the\n" - << "password here. The same file can be repeated multiple times. All\n" + << "password here. The same file can be repeated multiple times. The\n" + << "filename \".\" may be used to refer to the current input file. All\n" << "non-page data (info, outlines, page numbers, etc. are taken from the\n" << "primary input file. To discard this, use --empty as the primary\n" << "input.\n" @@ -3676,6 +3677,17 @@ static void handle_page_specs(QPDF& pdf, Options& o) // Parse all page specifications and translate them into lists of // actual pages. + // Handle "." as a shortcut for the input file + for (std::vector<PageSpec>::iterator iter = o.page_specs.begin(); + iter != o.page_specs.end(); ++iter) + { + PageSpec& page_spec = *iter; + if (page_spec.filename == ".") + { + page_spec.filename = o.infilename; + } + } + if (! o.keep_files_open_set) { // Count the number of distinct files to determine whether we diff --git a/qpdf/qtest/qpdf.test b/qpdf/qtest/qpdf.test index c36b8c95..b45f32a1 100644 --- a/qpdf/qtest/qpdf.test +++ b/qpdf/qtest/qpdf.test @@ -1692,11 +1692,10 @@ $td->runtest("check output", {$td->FILE => "a.pdf"}, {$td->FILE => "merge-multiple-labels.pdf"}); -$td->runtest("split with shared resources", +$td->runtest("split with shared resources", # QXXXQ {$td->COMMAND => "qpdf --qdf --static-id" . - " shared-images.pdf --pages" . - " shared-images.pdf 1,3" . + " shared-images.pdf --pages . 1,3" . " ./shared-images.pdf 1,2 -- a.pdf"}, {$td->STRING => "", $td->EXIT_STATUS => 0}); $td->runtest("check output", @@ -1706,8 +1705,7 @@ $td->runtest("check output", $td->runtest("shared resources relevant errors", {$td->COMMAND => "qpdf --qdf --static-id" . - " shared-images-errors.pdf --pages" . - " shared-images-errors.pdf 2 -- a.pdf"}, + " shared-images-errors.pdf --pages . 2 -- a.pdf"}, {$td->FILE => "shared-images-errors-2.out", $td->EXIT_STATUS => 3}, $td->NORMALIZE_NEWLINES); @@ -1718,8 +1716,7 @@ $td->runtest("check output", $td->runtest("shared resources irrelevant errors", {$td->COMMAND => "qpdf --qdf --static-id" . - " shared-images-errors.pdf --pages" . - " shared-images-errors.pdf 1 -- a.pdf"}, + " shared-images-errors.pdf --pages . 1 -- a.pdf"}, {$td->FILE => "shared-images-errors-1.out", $td->EXIT_STATUS => 3}, $td->NORMALIZE_NEWLINES); @@ -1730,8 +1727,7 @@ $td->runtest("check output", $td->runtest("don't remove shared resources", {$td->COMMAND => "qpdf --qdf --static-id --preserve-unreferenced-resources" . - " shared-images.pdf --pages" . - " shared-images.pdf 1,3 -- a.pdf"}, + " shared-images.pdf --pages . 1,3 -- a.pdf"}, {$td->STRING => "", $td->EXIT_STATUS => 0}); $td->runtest("check output", {$td->FILE => "a.pdf"}, |