2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-06-03 19:00:51 +00:00

Add --verbose flag

This commit is contained in:
Jay Berkenbilt 2017-08-12 12:30:18 -04:00
parent 2c6fe1805a
commit d926d78059
5 changed files with 35 additions and 4 deletions

View File

@ -1,5 +1,8 @@
2017-08-12 Jay Berkenbilt <ejb@ql.org> 2017-08-12 Jay Berkenbilt <ejb@ql.org>
* Provide --verbose option that causes qpdf to print an indication
of what files it is writing.
* Change --single-pages to --split-pages and make it take an * Change --single-pages to --split-pages and make it take an
optional argument specifying the number of pages per file. optional argument specifying the number of pages per file.

View File

@ -284,6 +284,15 @@ make
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><option>--verbose</option></term>
<listitem>
<para>
Increase verbosity of output. For now, this just prints some
indication of any file that it creates.
</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><option>--linearize</option></term> <term><option>--linearize</option></term>
<listitem> <listitem>

View File

@ -44,6 +44,7 @@ struct Options
linearize(false), linearize(false),
decrypt(false), decrypt(false),
split_pages(0), split_pages(0),
verbose(false),
copy_encryption(false), copy_encryption(false),
encryption_file(0), encryption_file(0),
encryption_file_password(0), encryption_file_password(0),
@ -99,6 +100,7 @@ struct Options
bool linearize; bool linearize;
bool decrypt; bool decrypt;
int split_pages; int split_pages;
bool verbose;
bool copy_encryption; bool copy_encryption;
char const* encryption_file; char const* encryption_file;
char const* encryption_file_password; char const* encryption_file_password;
@ -198,6 +200,7 @@ Basic Options\n\
-------------\n\ -------------\n\
\n\ \n\
--password=password specify a password for accessing encrypted files\n\ --password=password specify a password for accessing encrypted files\n\
--verbose provide additional informational output\n\
--linearize generated a linearized (web optimized) file\n\ --linearize generated a linearized (web optimized) file\n\
--copy-encryption=file copy encryption parameters from specified file\n\ --copy-encryption=file copy encryption parameters from specified file\n\
--encryption-file-password=password\n\ --encryption-file-password=password\n\
@ -1341,6 +1344,10 @@ static void parse_options(int argc, char* argv[], Options& o)
int n = ((parameter == 0) ? 1 : atoi(parameter)); int n = ((parameter == 0) ? 1 : atoi(parameter));
o.split_pages = n; o.split_pages = n;
} }
else if (strcmp(arg, "verbose") == 0)
{
o.verbose = true;
}
else if (strcmp(arg, "deterministic-id") == 0) else if (strcmp(arg, "deterministic-id") == 0)
{ {
o.deterministic_id = true; o.deterministic_id = true;
@ -2033,6 +2040,10 @@ static void write_outfile(QPDF& pdf, Options& o)
QPDFWriter w(outpdf, outfile.c_str()); QPDFWriter w(outpdf, outfile.c_str());
set_writer_options(outpdf, o, w); set_writer_options(outpdf, o, w);
w.write(); w.write();
if (o.verbose)
{
std::cout << whoami << ": wrote file " << outfile << std::endl;
}
} }
} }
else else
@ -2044,6 +2055,11 @@ static void write_outfile(QPDF& pdf, Options& o)
QPDFWriter w(pdf, o.outfilename); QPDFWriter w(pdf, o.outfilename);
set_writer_options(pdf, o, w); set_writer_options(pdf, o, w);
w.write(); w.write();
if (o.verbose && o.outfilename)
{
std::cout << whoami << ": wrote file "
<< o.outfilename << std::endl;
}
} }
} }

View File

@ -325,8 +325,8 @@ $td->runtest("check obj0.pdf",
# Min/Force version # Min/Force version
$td->runtest("set min version", $td->runtest("set min version",
{$td->COMMAND => "qpdf --min-version=1.6 good1.pdf a.pdf"}, {$td->COMMAND => "qpdf --verbose --min-version=1.6 good1.pdf a.pdf"},
{$td->STRING => "", {$td->STRING => "qpdf: wrote file a.pdf\n",
$td->EXIT_STATUS => 0}, $td->EXIT_STATUS => 0},
$td->NORMALIZE_NEWLINES); $td->NORMALIZE_NEWLINES);
$td->runtest("check version", $td->runtest("check version",
@ -730,8 +730,8 @@ for (@sp_cases)
$td->runtest("split page group > 1", $td->runtest("split page group > 1",
{$td->COMMAND => "qpdf --static-id --split-pages=5 11-pages.pdf" . {$td->COMMAND => "qpdf --static-id --split-pages=5 11-pages.pdf" .
" split-out-group.pdf"}, " --verbose split-out-group.pdf"},
{$td->STRING => "", $td->EXIT_STATUS => 0}, {$td->FILE => "split-pages-group.out", $td->EXIT_STATUS => 0},
$td->NORMALIZE_NEWLINES); $td->NORMALIZE_NEWLINES);
foreach my $f ('01-05', '06-10', '11-11') foreach my $f ('01-05', '06-10', '11-11')
{ {

View File

@ -0,0 +1,3 @@
qpdf: wrote file split-out-group-01-05.pdf
qpdf: wrote file split-out-group-06-10.pdf
qpdf: wrote file split-out-group-11-11.pdf