2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-22 02:49:00 +00:00

Add --remove-page-labels option (fixes #317)

This commit is contained in:
Jay Berkenbilt 2019-04-20 19:13:49 -04:00
parent e50d5201df
commit 2b011f9d81
5 changed files with 43 additions and 4 deletions

View File

@ -1,5 +1,12 @@
2019-04-20 Jay Berkenbilt <ejb@ql.org>
* Add parameter --remove-page-labels to remove page labels from
output. In qpdf 8.3.0, the behavior changed so that page labels
were preserved when merging and splitting files. Some users were
relying on the fact that if you ran qpdf --empty --pages ... all
page labels were dropped. This option makes it possible to get
that behavior if it is explicitly desired. Fixes #317.
* Add parameter --keep-files-open-threshold to override the
maximum number of files that qpdf will allow to be kept open at
once. Fixes #288.

View File

@ -1797,9 +1797,6 @@ outfile.pdf</option>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--externalize-inline-images</option></term>
<listitem>
@ -1834,6 +1831,14 @@ outfile.pdf</option>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--remove-page-labels</option></term>
<listitem>
<para>
Remove page labels from the output file.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--qdf</option></term>
<listitem>

View File

@ -164,6 +164,7 @@ struct Options
optimize_images(false),
externalize_inline_images(false),
keep_inline_images(false),
remove_page_labels(false),
oi_min_width(128), // Default values for these
oi_min_height(128), // oi flags are in --help
oi_min_area(16384), // and in the manual.
@ -261,6 +262,7 @@ struct Options
bool optimize_images;
bool externalize_inline_images;
bool keep_inline_images;
bool remove_page_labels;
size_t oi_min_width;
size_t oi_min_height;
size_t oi_min_area;
@ -670,6 +672,7 @@ class ArgParser
void argOptimizeImages();
void argExternalizeInlineImages();
void argKeepInlineImages();
void argRemovePageLabels();
void argOiMinWidth(char* parameter);
void argOiMinHeight(char* parameter);
void argOiMinArea(char* parameter);
@ -911,6 +914,7 @@ ArgParser::initOptionTable()
(*t)["externalize-inline-images"] =
oe_bare(&ArgParser::argExternalizeInlineImages);
(*t)["keep-inline-images"] = oe_bare(&ArgParser::argKeepInlineImages);
(*t)["remove-page-labels"] = oe_bare(&ArgParser::argRemovePageLabels);
(*t)["oi-min-width"] = oe_requiredParameter(
&ArgParser::argOiMinWidth, "minimum-width");
(*t)["oi-min-height"] = oe_requiredParameter(
@ -1335,6 +1339,7 @@ ArgParser::argHelp()
<< "--ii-min-bytes=bytes specify minimum size of inline images to be\n"
<< " converted to regular images\n"
<< "--keep-inline-images exclude inline images from image optimization\n"
<< "--remove-page-labels remove any page labels present in the output file\n"
<< "--qdf turns on \"QDF mode\" (below)\n"
<< "--linearize-pass1=file write intermediate pass of linearized file\n"
<< " for debugging\n"
@ -2012,6 +2017,12 @@ ArgParser::argKeepInlineImages()
o.keep_inline_images = true;
}
void
ArgParser::argRemovePageLabels()
{
o.remove_page_labels = true;
}
void
ArgParser::argOiMinWidth(char* parameter)
{
@ -4335,6 +4346,10 @@ static void handle_transformations(QPDF& pdf, Options& o)
(*iter).coalesceContentStreams();
}
}
if (o.remove_page_labels)
{
pdf.getRoot().removeKey("/PageLabels");
}
}
static void handle_page_specs(QPDF& pdf, Options& o)

View File

@ -1877,7 +1877,7 @@ foreach my $f (qw(page_api_2 direct-pages))
show_ntests();
# ----------
$td->notify("--- Merging and Splitting ---");
$n_tests += 22;
$n_tests += 24;
# Select pages from the same file multiple times including selecting
# twice from an encrypted file and specifying the password only the
@ -1944,6 +1944,18 @@ $td->runtest("merge with multiple labels",
$td->runtest("check output",
{$td->FILE => "a.pdf"},
{$td->FILE => "merge-multiple-labels.pdf"});
$td->runtest("remove labels",
{$td->COMMAND =>
"qpdf --empty a.pdf" .
" --remove-page-labels" .
" --pages 11-pages-with-labels.pdf 8-11" .
" minimal.pdf " .
" page-labels-and-outlines.pdf 17-19 --" .
" --static-id"},
{$td->STRING => "", $td->EXIT_STATUS => 0});
$td->runtest("check output",
{$td->FILE => "a.pdf"},
{$td->FILE => "remove-labels.pdf"});
$td->runtest("split with shared resources",
{$td->COMMAND =>

Binary file not shown.