2022-01-23 14:46:02 +00:00
|
|
|
#include <qpdf/QPDFJob.hh>
|
2022-01-24 00:46:20 +00:00
|
|
|
#include <qpdf/QUtil.hh>
|
2022-01-26 00:21:46 +00:00
|
|
|
#include <qpdf/QTC.hh>
|
2022-01-24 00:46:20 +00:00
|
|
|
#include <cstring>
|
2022-01-24 00:29:18 +00:00
|
|
|
|
2022-01-29 14:01:20 +00:00
|
|
|
void
|
|
|
|
QPDFJob::Config::checkConfiguration()
|
|
|
|
{
|
|
|
|
o.checkConfiguration();
|
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-26 18:56:13 +00:00
|
|
|
QPDFJob::Config::inputFile(char const* filename)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
if (o.m->infilename == 0)
|
2022-01-26 18:56:13 +00:00
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->infilename = QUtil::make_shared_cstr(filename);
|
2022-01-26 18:56:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
usage("input file has already been given");
|
|
|
|
}
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-26 18:56:13 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-26 18:56:13 +00:00
|
|
|
QPDFJob::Config::emptyInput()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
if (o.m->infilename == 0)
|
2022-01-26 18:56:13 +00:00
|
|
|
{
|
|
|
|
// QXXXQ decide whether to fix this or just leave the comment:
|
|
|
|
// Various places in QPDFJob.cc know that the empty string for
|
|
|
|
// infile means empty. This means that passing "" as the
|
|
|
|
// argument to inputFile, or equivalently using "" as a
|
|
|
|
// positional command-line argument would be the same as
|
|
|
|
// --empty. This probably isn't worth blocking or coding
|
|
|
|
// around, but it would be better if we had a tighter way of
|
|
|
|
// knowing that the input file is empty.
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->infilename = QUtil::make_shared_cstr("");
|
2022-01-26 18:56:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
usage("empty input can't be used"
|
|
|
|
" since input file has already been given");
|
|
|
|
}
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-26 18:56:13 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-26 18:56:13 +00:00
|
|
|
QPDFJob::Config::outputFile(char const* filename)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
if ((o.m->outfilename == 0) && (! o.m->replace_input))
|
2022-01-26 18:56:13 +00:00
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->outfilename = QUtil::make_shared_cstr(filename);
|
2022-01-26 18:56:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
usage("output file has already been given");
|
|
|
|
}
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-26 18:56:13 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-26 18:56:13 +00:00
|
|
|
QPDFJob::Config::replaceInput()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
if ((o.m->outfilename == 0) && (! o.m->replace_input))
|
2022-01-26 18:56:13 +00:00
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->replace_input = true;
|
2022-01-26 18:56:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
usage("replace-input can't be used"
|
|
|
|
" since output file has already been given");
|
|
|
|
}
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-26 18:56:13 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::allowWeakCrypto()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->allow_weak_crypto = true;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::check()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->check = true;
|
|
|
|
o.m->require_outfile = false;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::checkLinearization()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->check_linearization = true;
|
|
|
|
o.m->require_outfile = false;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::coalesceContents()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->coalesce_contents = true;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::collate(char const* parameter)
|
|
|
|
{
|
|
|
|
auto n = ((parameter == 0) ? 1 :
|
|
|
|
QUtil::string_to_uint(parameter));
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->collate = QIntC::to_size(n);
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::compressStreams(char const* parameter)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->compress_streams_set = true;
|
|
|
|
o.m->compress_streams = (strcmp(parameter, "y") == 0);
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::compressionLevel(char const* parameter)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->compression_level = QUtil::string_to_int(parameter);
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::copyEncryption(char const* parameter)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->encryption_file = parameter;
|
|
|
|
o.m->copy_encryption = true;
|
|
|
|
o.m->encrypt = false;
|
|
|
|
o.m->decrypt = false;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::decrypt()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->decrypt = true;
|
|
|
|
o.m->encrypt = false;
|
|
|
|
o.m->copy_encryption = false;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::deterministicId()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->deterministic_id = true;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::encryptionFilePassword(char const* parameter)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->encryption_file_password = QUtil::make_shared_cstr(parameter);
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::externalizeInlineImages()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->externalize_inline_images = true;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::filteredStreamData()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->show_filtered_stream_data = true;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::flattenAnnotations(char const* parameter)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->flatten_annotations = true;
|
2022-01-24 00:46:20 +00:00
|
|
|
if (strcmp(parameter, "screen") == 0)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->flatten_annotations_forbidden |= an_no_view;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(parameter, "print") == 0)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->flatten_annotations_required |= an_print;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::flattenRotation()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->flatten_rotation = true;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::forceVersion(char const* parameter)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->force_version = parameter;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::generateAppearances()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->generate_appearances = true;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::ignoreXrefStreams()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->ignore_xref_streams = true;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::iiMinBytes(char const* parameter)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->ii_min_bytes = QUtil::string_to_uint(parameter);
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::isEncrypted()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->check_is_encrypted = true;
|
|
|
|
o.m->require_outfile = false;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::json()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->json = true;
|
|
|
|
o.m->require_outfile = false;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::jsonKey(char const* parameter)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->json_keys.insert(parameter);
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::jsonObject(char const* parameter)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->json_objects.insert(parameter);
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::keepFilesOpen(char const* parameter)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->keep_files_open_set = true;
|
|
|
|
o.m->keep_files_open = (strcmp(parameter, "y") == 0);
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::keepFilesOpenThreshold(char const* parameter)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->keep_files_open_threshold = QUtil::string_to_uint(parameter);
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::keepInlineImages()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->keep_inline_images = true;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::linearize()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->linearize = true;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::linearizePass1(char const* parameter)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->linearize_pass1 = parameter;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::listAttachments()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->list_attachments = true;
|
|
|
|
o.m->require_outfile = false;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::minVersion(char const* parameter)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->min_version = parameter;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::newlineBeforeEndstream()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->newline_before_endstream = true;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::noOriginalObjectIds()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->suppress_original_object_id = true;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::noWarn()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->suppress_warnings = true;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::normalizeContent(char const* parameter)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->normalize_set = true;
|
|
|
|
o.m->normalize = (strcmp(parameter, "y") == 0);
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::oiMinArea(char const* parameter)
|
|
|
|
{
|
2022-01-26 21:40:14 +00:00
|
|
|
o.m->oi_min_area = QUtil::string_to_uint(parameter);
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::oiMinHeight(char const* parameter)
|
|
|
|
{
|
2022-01-26 21:40:14 +00:00
|
|
|
o.m->oi_min_height = QUtil::string_to_uint(parameter);
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::oiMinWidth(char const* parameter)
|
|
|
|
{
|
2022-01-26 21:40:14 +00:00
|
|
|
o.m->oi_min_width = QUtil::string_to_uint(parameter);
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::optimizeImages()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->optimize_images = true;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-25 16:14:43 +00:00
|
|
|
QPDFJob::Config::password(char const* parameter)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->password = QUtil::make_shared_cstr(parameter);
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-25 16:14:43 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::passwordIsHexKey()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->password_is_hex_key = true;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::preserveUnreferenced()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->preserve_unreferenced_objects = true;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::preserveUnreferencedResources()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->remove_unreferenced_page_resources = QPDFJob::re_no;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::progress()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->progress = true;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::qdf()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->qdf_mode = true;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::rawStreamData()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->show_raw_stream_data = true;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::recompressFlate()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->recompress_flate_set = true;
|
|
|
|
o.m->recompress_flate = true;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::removeAttachment(char const* parameter)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->attachments_to_remove.push_back(parameter);
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::removePageLabels()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->remove_page_labels = true;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::requiresPassword()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->check_requires_password = true;
|
|
|
|
o.m->require_outfile = false;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::showAttachment(char const* parameter)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->attachment_to_show = parameter;
|
|
|
|
o.m->require_outfile = false;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::showEncryption()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->show_encryption = true;
|
|
|
|
o.m->require_outfile = false;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::showEncryptionKey()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->show_encryption_key = true;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::showLinearization()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->show_linearization = true;
|
|
|
|
o.m->require_outfile = false;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::showNpages()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->show_npages = true;
|
|
|
|
o.m->require_outfile = false;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::showPages()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->show_pages = true;
|
|
|
|
o.m->require_outfile = false;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::showXref()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->show_xref = true;
|
|
|
|
o.m->require_outfile = false;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::splitPages(char const* parameter)
|
|
|
|
{
|
|
|
|
int n = ((parameter == 0) ? 1 :
|
|
|
|
QUtil::string_to_int(parameter));
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->split_pages = n;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::staticAesIv()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->static_aes_iv = true;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::staticId()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->static_id = true;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::suppressPasswordRecovery()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->suppress_password_recovery = true;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::suppressRecovery()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->suppress_recovery = true;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::verbose()
|
2022-01-24 00:29:18 +00:00
|
|
|
{
|
|
|
|
o.m->verbose = true;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:29:18 +00:00
|
|
|
}
|
2022-01-24 00:46:20 +00:00
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::warningExit0()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->warnings_exit_zero = true;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-24 00:46:20 +00:00
|
|
|
QPDFJob::Config::withImages()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->show_page_images = true;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
2022-01-25 16:07:53 +00:00
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-26 00:21:46 +00:00
|
|
|
QPDFJob::Config::passwordFile(char const* parameter)
|
|
|
|
{
|
|
|
|
std::list<std::string> lines;
|
|
|
|
if (strcmp(parameter, "-") == 0)
|
|
|
|
{
|
|
|
|
QTC::TC("qpdf", "QPDFJob_config password stdin");
|
|
|
|
lines = QUtil::read_lines_from_file(std::cin);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QTC::TC("qpdf", "QPDFJob_config password file");
|
|
|
|
lines = QUtil::read_lines_from_file(parameter);
|
|
|
|
}
|
|
|
|
if (lines.size() >= 1)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->password = QUtil::make_shared_cstr(lines.front());
|
2022-01-26 00:21:46 +00:00
|
|
|
|
|
|
|
if (lines.size() > 1)
|
|
|
|
{
|
|
|
|
std::cerr << this->o.m->message_prefix
|
|
|
|
<< ": WARNING: all but the first line of"
|
|
|
|
<< " the password file are ignored" << std::endl;
|
|
|
|
}
|
|
|
|
}
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-26 00:21:46 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-26 00:21:46 +00:00
|
|
|
QPDFJob::Config::passwordMode(char const* parameter)
|
|
|
|
{
|
|
|
|
if (strcmp(parameter, "bytes") == 0)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->password_mode = QPDFJob::pm_bytes;
|
2022-01-26 00:21:46 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(parameter, "hex-bytes") == 0)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->password_mode = QPDFJob::pm_hex_bytes;
|
2022-01-26 00:21:46 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(parameter, "unicode") == 0)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->password_mode = QPDFJob::pm_unicode;
|
2022-01-26 00:21:46 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(parameter, "auto") == 0)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->password_mode = QPDFJob::pm_auto;
|
2022-01-26 00:21:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
usage("invalid password-mode option");
|
|
|
|
}
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-26 00:21:46 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-26 00:21:46 +00:00
|
|
|
QPDFJob::Config::streamData(char const* parameter)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->stream_data_set = true;
|
2022-01-26 00:21:46 +00:00
|
|
|
if (strcmp(parameter, "compress") == 0)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->stream_data_mode = qpdf_s_compress;
|
2022-01-26 00:21:46 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(parameter, "preserve") == 0)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->stream_data_mode = qpdf_s_preserve;
|
2022-01-26 00:21:46 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(parameter, "uncompress") == 0)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->stream_data_mode = qpdf_s_uncompress;
|
2022-01-26 00:21:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// If this happens, it means streamDataChoices in
|
|
|
|
// ArgParser::initOptionTable is wrong.
|
|
|
|
usage("invalid stream-data option");
|
|
|
|
}
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-26 00:21:46 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-26 00:21:46 +00:00
|
|
|
QPDFJob::Config::decodeLevel(char const* parameter)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->decode_level_set = true;
|
2022-01-26 00:21:46 +00:00
|
|
|
if (strcmp(parameter, "none") == 0)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->decode_level = qpdf_dl_none;
|
2022-01-26 00:21:46 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(parameter, "generalized") == 0)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->decode_level = qpdf_dl_generalized;
|
2022-01-26 00:21:46 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(parameter, "specialized") == 0)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->decode_level = qpdf_dl_specialized;
|
2022-01-26 00:21:46 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(parameter, "all") == 0)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->decode_level = qpdf_dl_all;
|
2022-01-26 00:21:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// If this happens, it means decodeLevelChoices in
|
|
|
|
// ArgParser::initOptionTable is wrong.
|
|
|
|
usage("invalid option");
|
|
|
|
}
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-26 00:21:46 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-26 00:21:46 +00:00
|
|
|
QPDFJob::Config::objectStreams(char const* parameter)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->object_stream_set = true;
|
2022-01-26 00:21:46 +00:00
|
|
|
if (strcmp(parameter, "disable") == 0)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->object_stream_mode = qpdf_o_disable;
|
2022-01-26 00:21:46 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(parameter, "preserve") == 0)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->object_stream_mode = qpdf_o_preserve;
|
2022-01-26 00:21:46 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(parameter, "generate") == 0)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->object_stream_mode = qpdf_o_generate;
|
2022-01-26 00:21:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// If this happens, it means objectStreamsChoices in
|
|
|
|
// ArgParser::initOptionTable is wrong.
|
|
|
|
usage("invalid object stream mode");
|
|
|
|
}
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-26 00:21:46 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-26 00:21:46 +00:00
|
|
|
QPDFJob::Config::removeUnreferencedResources(char const* parameter)
|
|
|
|
{
|
|
|
|
if (strcmp(parameter, "auto") == 0)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->remove_unreferenced_page_resources = QPDFJob::re_auto;
|
2022-01-26 00:21:46 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(parameter, "yes") == 0)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->remove_unreferenced_page_resources = QPDFJob::re_yes;
|
2022-01-26 00:21:46 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(parameter, "no") == 0)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->remove_unreferenced_page_resources = QPDFJob::re_no;
|
2022-01-26 00:21:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// If this happens, it means remove_unref_choices in
|
|
|
|
// ArgParser::initOptionTable is wrong.
|
|
|
|
usage("invalid value for --remove-unreferenced-page-resources");
|
|
|
|
}
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-26 00:21:46 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-26 00:21:46 +00:00
|
|
|
QPDFJob::Config::showObject(char const* parameter)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
QPDFJob::parse_object_id(
|
|
|
|
parameter, o.m->show_trailer, o.m->show_obj, o.m->show_gen);
|
|
|
|
o.m->require_outfile = false;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-26 00:21:46 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-26 00:21:46 +00:00
|
|
|
QPDFJob::Config::jobJsonFile(char const* parameter)
|
|
|
|
{
|
|
|
|
PointerHolder<char> file_buf;
|
|
|
|
size_t size;
|
|
|
|
QUtil::read_file_into_memory(parameter, file_buf, size);
|
|
|
|
try
|
|
|
|
{
|
|
|
|
o.initializeFromJson(std::string(file_buf.getPointer(), size));
|
|
|
|
}
|
|
|
|
catch (std::exception& e)
|
|
|
|
{
|
|
|
|
throw std::runtime_error(
|
2022-01-29 17:53:35 +00:00
|
|
|
"error with job-json file " + std::string(parameter) + ": " +
|
2022-01-26 00:21:46 +00:00
|
|
|
e.what() + "\nRun " + this->o.m->message_prefix +
|
|
|
|
"--job-json-help for information on the file format.");
|
|
|
|
}
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-26 00:21:46 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-26 14:38:34 +00:00
|
|
|
QPDFJob::Config::rotate(char const* parameter)
|
|
|
|
{
|
|
|
|
o.parseRotationParameter(parameter);
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-26 14:38:34 +00:00
|
|
|
}
|
|
|
|
|
2022-01-25 16:07:53 +00:00
|
|
|
std::shared_ptr<QPDFJob::CopyAttConfig>
|
|
|
|
QPDFJob::Config::copyAttachmentsFrom()
|
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
return std::shared_ptr<CopyAttConfig>(new CopyAttConfig(this));
|
2022-01-25 16:07:53 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::CopyAttConfig::CopyAttConfig(Config* c) :
|
2022-01-25 16:07:53 +00:00
|
|
|
config(c)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::CopyAttConfig*
|
2022-01-25 21:37:17 +00:00
|
|
|
QPDFJob::CopyAttConfig::path(char const* parameter)
|
2022-01-25 16:07:53 +00:00
|
|
|
{
|
|
|
|
this->caf.path = parameter;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-25 16:07:53 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::CopyAttConfig*
|
2022-01-25 16:07:53 +00:00
|
|
|
QPDFJob::CopyAttConfig::prefix(char const* parameter)
|
|
|
|
{
|
|
|
|
this->caf.prefix = parameter;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-25 16:07:53 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::CopyAttConfig*
|
2022-01-25 16:07:53 +00:00
|
|
|
QPDFJob::CopyAttConfig::password(char const* parameter)
|
|
|
|
{
|
|
|
|
this->caf.password = parameter;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-25 16:07:53 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-26 22:02:30 +00:00
|
|
|
QPDFJob::CopyAttConfig::endCopyAttachmentsFrom()
|
2022-01-25 16:07:53 +00:00
|
|
|
{
|
|
|
|
if (this->caf.path.empty())
|
|
|
|
{
|
2022-01-26 00:21:46 +00:00
|
|
|
usage("copy attachments: no path specified");
|
2022-01-25 16:07:53 +00:00
|
|
|
}
|
2022-01-26 22:18:03 +00:00
|
|
|
this->config->o.m->attachments_to_copy.push_back(this->caf);
|
2022-01-25 16:07:53 +00:00
|
|
|
return this->config;
|
|
|
|
}
|
2022-01-25 21:37:17 +00:00
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::AttConfig::AttConfig(Config* c) :
|
2022-01-25 21:37:17 +00:00
|
|
|
config(c)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
std::shared_ptr<QPDFJob::AttConfig>
|
|
|
|
QPDFJob::Config::addAttachment()
|
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
return std::shared_ptr<AttConfig>(new AttConfig(this));
|
2022-01-25 21:37:17 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::AttConfig*
|
2022-01-25 21:37:17 +00:00
|
|
|
QPDFJob::AttConfig::path(char const* parameter)
|
|
|
|
{
|
|
|
|
this->att.path = parameter;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-25 21:37:17 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::AttConfig*
|
2022-01-25 21:37:17 +00:00
|
|
|
QPDFJob::AttConfig::key(char const* parameter)
|
|
|
|
{
|
|
|
|
this->att.key = parameter;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-25 21:37:17 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::AttConfig*
|
2022-01-25 21:37:17 +00:00
|
|
|
QPDFJob::AttConfig::filename(char const* parameter)
|
|
|
|
{
|
|
|
|
this->att.filename = parameter;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-25 21:37:17 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::AttConfig*
|
2022-01-25 21:37:17 +00:00
|
|
|
QPDFJob::AttConfig::creationdate(char const* parameter)
|
|
|
|
{
|
|
|
|
if (! QUtil::pdf_time_to_qpdf_time(parameter))
|
|
|
|
{
|
2022-01-26 00:21:46 +00:00
|
|
|
usage(std::string(parameter) + " is not a valid PDF timestamp");
|
2022-01-25 21:37:17 +00:00
|
|
|
}
|
|
|
|
this->att.creationdate = parameter;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-25 21:37:17 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::AttConfig*
|
2022-01-25 21:37:17 +00:00
|
|
|
QPDFJob::AttConfig::moddate(char const* parameter)
|
|
|
|
{
|
|
|
|
if (! QUtil::pdf_time_to_qpdf_time(parameter))
|
|
|
|
{
|
2022-01-26 00:21:46 +00:00
|
|
|
usage(std::string(parameter) + " is not a valid PDF timestamp");
|
2022-01-25 21:37:17 +00:00
|
|
|
}
|
|
|
|
this->att.moddate = parameter;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-25 21:37:17 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::AttConfig*
|
2022-01-25 21:37:17 +00:00
|
|
|
QPDFJob::AttConfig::mimetype(char const* parameter)
|
|
|
|
{
|
|
|
|
if (strchr(parameter, '/') == nullptr)
|
|
|
|
{
|
2022-01-26 00:21:46 +00:00
|
|
|
usage("mime type should be specified as type/subtype");
|
2022-01-25 21:37:17 +00:00
|
|
|
}
|
|
|
|
this->att.mimetype = parameter;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-25 21:37:17 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::AttConfig*
|
2022-01-25 21:37:17 +00:00
|
|
|
QPDFJob::AttConfig::description(char const* parameter)
|
|
|
|
{
|
|
|
|
this->att.description = parameter;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-25 21:37:17 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::AttConfig*
|
2022-01-25 21:37:17 +00:00
|
|
|
QPDFJob::AttConfig::replace()
|
|
|
|
{
|
|
|
|
this->att.replace = true;
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-25 21:37:17 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-26 22:02:30 +00:00
|
|
|
QPDFJob::AttConfig::endAddAttachment()
|
2022-01-25 21:37:17 +00:00
|
|
|
{
|
|
|
|
static std::string now = QUtil::qpdf_time_to_pdf_time(
|
|
|
|
QUtil::get_current_qpdf_time());
|
|
|
|
if (this->att.path.empty())
|
|
|
|
{
|
2022-01-26 00:21:46 +00:00
|
|
|
usage("add attachment: no path specified");
|
2022-01-25 21:37:17 +00:00
|
|
|
}
|
|
|
|
std::string last_element = QUtil::path_basename(this->att.path);
|
|
|
|
if (last_element.empty())
|
|
|
|
{
|
2022-01-26 00:21:46 +00:00
|
|
|
usage("path for --add-attachment may not be empty");
|
2022-01-25 21:37:17 +00:00
|
|
|
}
|
|
|
|
if (this->att.filename.empty())
|
|
|
|
{
|
|
|
|
this->att.filename = last_element;
|
|
|
|
}
|
|
|
|
if (this->att.key.empty())
|
|
|
|
{
|
|
|
|
this->att.key = last_element;
|
|
|
|
}
|
|
|
|
if (this->att.creationdate.empty())
|
|
|
|
{
|
|
|
|
this->att.creationdate = now;
|
|
|
|
}
|
|
|
|
if (this->att.moddate.empty())
|
|
|
|
{
|
|
|
|
this->att.moddate = now;
|
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
this->config->o.m->attachments_to_add.push_back(this->att);
|
2022-01-25 21:37:17 +00:00
|
|
|
return this->config;
|
|
|
|
}
|
2022-01-26 00:01:10 +00:00
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::PagesConfig::PagesConfig(Config* c) :
|
2022-01-26 00:01:10 +00:00
|
|
|
config(c)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
std::shared_ptr<QPDFJob::PagesConfig>
|
|
|
|
QPDFJob::Config::pages()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
if (! o.m->page_specs.empty())
|
2022-01-26 18:39:22 +00:00
|
|
|
{
|
|
|
|
usage("--pages may only be specified one time");
|
|
|
|
}
|
2022-01-26 22:18:03 +00:00
|
|
|
return std::shared_ptr<PagesConfig>(new PagesConfig(this));
|
2022-01-26 00:01:10 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-26 22:02:30 +00:00
|
|
|
QPDFJob::PagesConfig::endPages()
|
2022-01-26 00:01:10 +00:00
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
if (this->config->o.m->page_specs.empty())
|
2022-01-26 00:01:10 +00:00
|
|
|
{
|
2022-01-26 00:21:46 +00:00
|
|
|
usage("--pages: no page specifications given");
|
2022-01-26 00:01:10 +00:00
|
|
|
}
|
|
|
|
return this->config;
|
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::PagesConfig*
|
2022-01-26 00:01:10 +00:00
|
|
|
QPDFJob::PagesConfig::pageSpec(std::string const& filename,
|
2022-01-26 20:46:02 +00:00
|
|
|
std::string const& range,
|
|
|
|
char const* password)
|
2022-01-26 00:01:10 +00:00
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
this->config->o.m->page_specs.push_back(
|
2022-01-26 00:01:10 +00:00
|
|
|
QPDFJob::PageSpec(filename, password, range));
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-26 00:01:10 +00:00
|
|
|
}
|
2022-01-26 14:38:34 +00:00
|
|
|
|
|
|
|
std::shared_ptr<QPDFJob::UOConfig>
|
|
|
|
QPDFJob::Config::overlay()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->under_overlay = &o.m->overlay;
|
2022-01-26 22:18:03 +00:00
|
|
|
return std::shared_ptr<UOConfig>(new UOConfig(this));
|
2022-01-26 14:38:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::shared_ptr<QPDFJob::UOConfig>
|
|
|
|
QPDFJob::Config::underlay()
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->under_overlay = &o.m->underlay;
|
2022-01-26 22:18:03 +00:00
|
|
|
return std::shared_ptr<UOConfig>(new UOConfig(this));
|
2022-01-26 14:38:34 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::UOConfig::UOConfig(Config* c) :
|
2022-01-26 14:38:34 +00:00
|
|
|
config(c)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-26 22:02:30 +00:00
|
|
|
QPDFJob::UOConfig::endUnderlayOverlay()
|
2022-01-26 14:38:34 +00:00
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
if (config->o.m->under_overlay->filename.empty())
|
2022-01-26 14:38:34 +00:00
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
usage(config->o.m->under_overlay->which + " file not specified");
|
2022-01-26 14:38:34 +00:00
|
|
|
}
|
2022-01-26 22:18:03 +00:00
|
|
|
config->o.m->under_overlay = 0;
|
2022-01-26 14:38:34 +00:00
|
|
|
return this->config;
|
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::UOConfig*
|
2022-01-26 14:38:34 +00:00
|
|
|
QPDFJob::UOConfig::path(char const* parameter)
|
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
if (! config->o.m->under_overlay->filename.empty())
|
2022-01-26 14:38:34 +00:00
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
usage(config->o.m->under_overlay->which + " file already specified");
|
2022-01-26 14:38:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
config->o.m->under_overlay->filename = parameter;
|
2022-01-26 14:38:34 +00:00
|
|
|
}
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-26 14:38:34 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::UOConfig*
|
2022-01-26 14:38:34 +00:00
|
|
|
QPDFJob::UOConfig::to(char const* parameter)
|
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
config->o.parseNumrange(parameter, 0);
|
|
|
|
config->o.m->under_overlay->to_nr = parameter;
|
|
|
|
return this;
|
2022-01-26 14:38:34 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::UOConfig*
|
2022-01-26 14:38:34 +00:00
|
|
|
QPDFJob::UOConfig::from(char const* parameter)
|
|
|
|
{
|
|
|
|
if (strlen(parameter))
|
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
config->o.parseNumrange(parameter, 0);
|
2022-01-26 14:38:34 +00:00
|
|
|
}
|
2022-01-26 22:18:03 +00:00
|
|
|
config->o.m->under_overlay->from_nr = parameter;
|
|
|
|
return this;
|
2022-01-26 14:38:34 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::UOConfig*
|
2022-01-26 14:38:34 +00:00
|
|
|
QPDFJob::UOConfig::repeat(char const* parameter)
|
|
|
|
{
|
|
|
|
if (strlen(parameter))
|
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
config->o.parseNumrange(parameter, 0);
|
2022-01-26 14:38:34 +00:00
|
|
|
}
|
2022-01-26 22:18:03 +00:00
|
|
|
config->o.m->under_overlay->repeat_nr = parameter;
|
|
|
|
return this;
|
2022-01-26 14:38:34 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::UOConfig*
|
2022-01-26 14:38:34 +00:00
|
|
|
QPDFJob::UOConfig::password(char const* parameter)
|
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
config->o.m->under_overlay->password = QUtil::make_shared_cstr(parameter);
|
|
|
|
return this;
|
2022-01-26 14:38:34 +00:00
|
|
|
}
|
2022-01-26 18:17:57 +00:00
|
|
|
|
|
|
|
std::shared_ptr<QPDFJob::EncConfig>
|
|
|
|
QPDFJob::Config::encrypt(int keylen,
|
|
|
|
std::string const& user_password,
|
|
|
|
std::string const& owner_password)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->keylen = keylen;
|
2022-01-26 18:17:57 +00:00
|
|
|
if (keylen == 256)
|
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->use_aes = true;
|
2022-01-26 18:17:57 +00:00
|
|
|
}
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->user_password = user_password;
|
|
|
|
o.m->owner_password = owner_password;
|
2022-01-26 22:18:03 +00:00
|
|
|
return std::shared_ptr<EncConfig>(new EncConfig(this));
|
2022-01-26 18:17:57 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::EncConfig::EncConfig(Config* c) :
|
2022-01-26 18:17:57 +00:00
|
|
|
config(c)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-01-26 22:02:30 +00:00
|
|
|
QPDFJob::EncConfig::endEncrypt()
|
2022-01-26 18:17:57 +00:00
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
config->o.m->encrypt = true;
|
|
|
|
config->o.m->decrypt = false;
|
|
|
|
config->o.m->copy_encryption = false;
|
2022-01-26 18:17:57 +00:00
|
|
|
return this->config;
|
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::EncConfig*
|
2022-01-26 18:17:57 +00:00
|
|
|
QPDFJob::EncConfig::allowInsecure()
|
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
config->o.m->allow_insecure = true;
|
|
|
|
return this;
|
2022-01-26 18:17:57 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::EncConfig*
|
2022-01-26 18:17:57 +00:00
|
|
|
QPDFJob::EncConfig::accessibility(char const* parameter)
|
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
config->o.m->r3_accessibility = (strcmp(parameter, "y") == 0);
|
|
|
|
return this;
|
2022-01-26 18:17:57 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::EncConfig*
|
2022-01-26 18:17:57 +00:00
|
|
|
QPDFJob::EncConfig::extract(char const* parameter)
|
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
if (config->o.m->keylen == 40)
|
2022-01-26 18:17:57 +00:00
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
config->o.m->r2_extract = (strcmp(parameter, "y") == 0);
|
2022-01-26 18:17:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
config->o.m->r3_extract = (strcmp(parameter, "y") == 0);
|
2022-01-26 18:17:57 +00:00
|
|
|
}
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-26 18:17:57 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::EncConfig*
|
2022-01-26 18:17:57 +00:00
|
|
|
QPDFJob::EncConfig::print(char const* parameter)
|
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
if (config->o.m->keylen == 40)
|
2022-01-26 18:17:57 +00:00
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
config->o.m->r2_print = (strcmp(parameter, "y") == 0);
|
2022-01-26 18:17:57 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(parameter, "full") == 0)
|
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
config->o.m->r3_print = qpdf_r3p_full;
|
2022-01-26 18:17:57 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(parameter, "low") == 0)
|
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
config->o.m->r3_print = qpdf_r3p_low;
|
2022-01-26 18:17:57 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(parameter, "none") == 0)
|
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
config->o.m->r3_print = qpdf_r3p_none;
|
2022-01-26 18:17:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
usage("invalid print option");
|
|
|
|
}
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-26 18:17:57 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::EncConfig*
|
2022-01-26 18:17:57 +00:00
|
|
|
QPDFJob::EncConfig::modify(char const* parameter)
|
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
if (config->o.m->keylen == 40)
|
2022-01-26 18:17:57 +00:00
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
config->o.m->r2_modify = (strcmp(parameter, "y") == 0);
|
2022-01-26 18:17:57 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(parameter, "all") == 0)
|
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
config->o.m->r3_assemble = true;
|
|
|
|
config->o.m->r3_annotate_and_form = true;
|
|
|
|
config->o.m->r3_form_filling = true;
|
|
|
|
config->o.m->r3_modify_other = true;
|
2022-01-26 18:17:57 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(parameter, "annotate") == 0)
|
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
config->o.m->r3_assemble = true;
|
|
|
|
config->o.m->r3_annotate_and_form = true;
|
|
|
|
config->o.m->r3_form_filling = true;
|
|
|
|
config->o.m->r3_modify_other = false;
|
2022-01-26 18:17:57 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(parameter, "form") == 0)
|
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
config->o.m->r3_assemble = true;
|
|
|
|
config->o.m->r3_annotate_and_form = false;
|
|
|
|
config->o.m->r3_form_filling = true;
|
|
|
|
config->o.m->r3_modify_other = false;
|
2022-01-26 18:17:57 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(parameter, "assembly") == 0)
|
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
config->o.m->r3_assemble = true;
|
|
|
|
config->o.m->r3_annotate_and_form = false;
|
|
|
|
config->o.m->r3_form_filling = false;
|
|
|
|
config->o.m->r3_modify_other = false;
|
2022-01-26 18:17:57 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(parameter, "none") == 0)
|
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
config->o.m->r3_assemble = false;
|
|
|
|
config->o.m->r3_annotate_and_form = false;
|
|
|
|
config->o.m->r3_form_filling = false;
|
|
|
|
config->o.m->r3_modify_other = false;
|
2022-01-26 18:17:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
usage("invalid modify option");
|
|
|
|
}
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-26 18:17:57 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::EncConfig*
|
2022-01-26 18:17:57 +00:00
|
|
|
QPDFJob::EncConfig::cleartextMetadata()
|
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
config->o.m->cleartext_metadata = true;
|
|
|
|
return this;
|
2022-01-26 18:17:57 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::EncConfig*
|
2022-01-26 18:17:57 +00:00
|
|
|
QPDFJob::EncConfig::assemble(char const* parameter)
|
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
config->o.m->r3_assemble = (strcmp(parameter, "y") == 0);
|
|
|
|
return this;
|
2022-01-26 18:17:57 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::EncConfig*
|
2022-01-26 18:17:57 +00:00
|
|
|
QPDFJob::EncConfig::annotate(char const* parameter)
|
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
if (config->o.m->keylen == 40)
|
2022-01-26 18:17:57 +00:00
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
config->o.m->r2_annotate = (strcmp(parameter, "y") == 0);
|
2022-01-26 18:17:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
config->o.m->r3_annotate_and_form = (strcmp(parameter, "y") == 0);
|
2022-01-26 18:17:57 +00:00
|
|
|
}
|
2022-01-26 22:18:03 +00:00
|
|
|
return this;
|
2022-01-26 18:17:57 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::EncConfig*
|
2022-01-26 18:17:57 +00:00
|
|
|
QPDFJob::EncConfig::form(char const* parameter)
|
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
config->o.m->r3_form_filling = (strcmp(parameter, "y") == 0);
|
|
|
|
return this;
|
2022-01-26 18:17:57 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::EncConfig*
|
2022-01-26 18:17:57 +00:00
|
|
|
QPDFJob::EncConfig::modifyOther(char const* parameter)
|
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
config->o.m->r3_modify_other = (strcmp(parameter, "y") == 0);
|
|
|
|
return this;
|
2022-01-26 18:17:57 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::EncConfig*
|
2022-01-26 18:17:57 +00:00
|
|
|
QPDFJob::EncConfig::useAes(char const* parameter)
|
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
config->o.m->use_aes = (strcmp(parameter, "y") == 0);
|
|
|
|
return this;
|
2022-01-26 18:17:57 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::EncConfig*
|
2022-01-26 18:17:57 +00:00
|
|
|
QPDFJob::EncConfig::forceV4()
|
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
config->o.m->force_V4 = true;
|
|
|
|
return this;
|
2022-01-26 18:17:57 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::EncConfig*
|
2022-01-26 18:17:57 +00:00
|
|
|
QPDFJob::EncConfig::forceR5()
|
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
config->o.m->force_R5 = true;
|
|
|
|
return this;
|
2022-01-26 18:17:57 +00:00
|
|
|
}
|