mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-22 02:49:00 +00:00
Add --verbose flag
This commit is contained in:
parent
2c6fe1805a
commit
d926d78059
@ -1,5 +1,8 @@
|
||||
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
|
||||
optional argument specifying the number of pages per file.
|
||||
|
||||
|
@ -284,6 +284,15 @@ make
|
||||
</para>
|
||||
</listitem>
|
||||
</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>
|
||||
<term><option>--linearize</option></term>
|
||||
<listitem>
|
||||
|
16
qpdf/qpdf.cc
16
qpdf/qpdf.cc
@ -44,6 +44,7 @@ struct Options
|
||||
linearize(false),
|
||||
decrypt(false),
|
||||
split_pages(0),
|
||||
verbose(false),
|
||||
copy_encryption(false),
|
||||
encryption_file(0),
|
||||
encryption_file_password(0),
|
||||
@ -99,6 +100,7 @@ struct Options
|
||||
bool linearize;
|
||||
bool decrypt;
|
||||
int split_pages;
|
||||
bool verbose;
|
||||
bool copy_encryption;
|
||||
char const* encryption_file;
|
||||
char const* encryption_file_password;
|
||||
@ -198,6 +200,7 @@ Basic Options\n\
|
||||
-------------\n\
|
||||
\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\
|
||||
--copy-encryption=file copy encryption parameters from specified file\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));
|
||||
o.split_pages = n;
|
||||
}
|
||||
else if (strcmp(arg, "verbose") == 0)
|
||||
{
|
||||
o.verbose = true;
|
||||
}
|
||||
else if (strcmp(arg, "deterministic-id") == 0)
|
||||
{
|
||||
o.deterministic_id = true;
|
||||
@ -2033,6 +2040,10 @@ static void write_outfile(QPDF& pdf, Options& o)
|
||||
QPDFWriter w(outpdf, outfile.c_str());
|
||||
set_writer_options(outpdf, o, w);
|
||||
w.write();
|
||||
if (o.verbose)
|
||||
{
|
||||
std::cout << whoami << ": wrote file " << outfile << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -2044,6 +2055,11 @@ static void write_outfile(QPDF& pdf, Options& o)
|
||||
QPDFWriter w(pdf, o.outfilename);
|
||||
set_writer_options(pdf, o, w);
|
||||
w.write();
|
||||
if (o.verbose && o.outfilename)
|
||||
{
|
||||
std::cout << whoami << ": wrote file "
|
||||
<< o.outfilename << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -325,8 +325,8 @@ $td->runtest("check obj0.pdf",
|
||||
|
||||
# Min/Force version
|
||||
$td->runtest("set min version",
|
||||
{$td->COMMAND => "qpdf --min-version=1.6 good1.pdf a.pdf"},
|
||||
{$td->STRING => "",
|
||||
{$td->COMMAND => "qpdf --verbose --min-version=1.6 good1.pdf a.pdf"},
|
||||
{$td->STRING => "qpdf: wrote file a.pdf\n",
|
||||
$td->EXIT_STATUS => 0},
|
||||
$td->NORMALIZE_NEWLINES);
|
||||
$td->runtest("check version",
|
||||
@ -730,8 +730,8 @@ for (@sp_cases)
|
||||
|
||||
$td->runtest("split page group > 1",
|
||||
{$td->COMMAND => "qpdf --static-id --split-pages=5 11-pages.pdf" .
|
||||
" split-out-group.pdf"},
|
||||
{$td->STRING => "", $td->EXIT_STATUS => 0},
|
||||
" --verbose split-out-group.pdf"},
|
||||
{$td->FILE => "split-pages-group.out", $td->EXIT_STATUS => 0},
|
||||
$td->NORMALIZE_NEWLINES);
|
||||
foreach my $f ('01-05', '06-10', '11-11')
|
||||
{
|
||||
|
3
qpdf/qtest/qpdf/split-pages-group.out
Normal file
3
qpdf/qtest/qpdf/split-pages-group.out
Normal 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
|
Loading…
Reference in New Issue
Block a user