2022-01-23 14:46:02 +00:00
|
|
|
#include <qpdf/QPDFJob.hh>
|
2022-02-04 21:31:31 +00:00
|
|
|
|
2022-06-18 14:33:27 +00:00
|
|
|
#include <qpdf/QPDFLogger.hh>
|
2022-01-26 00:21:46 +00:00
|
|
|
#include <qpdf/QTC.hh>
|
2022-01-24 00:46:20 +00:00
|
|
|
#include <qpdf/QUtil.hh>
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::Config::inputFile(std::string const& filename)
|
2022-01-26 18:56:13 +00:00
|
|
|
{
|
2022-07-26 11:37:50 +00:00
|
|
|
if (o.m->infilename == nullptr) {
|
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-07-26 11:37:50 +00:00
|
|
|
if (o.m->infilename == nullptr) {
|
2022-01-26 18:56:13 +00:00
|
|
|
// Various places in QPDFJob.cc know that the empty string for infile means empty. We set it
|
2022-05-08 17:42:16 +00:00
|
|
|
// to something other than a null pointer as an indication that some input source has been
|
2022-05-18 22:22:57 +00:00
|
|
|
// specified. This approach means that passing "" as the argument to inputFile in job JSON,
|
2022-05-08 17:42:16 +00:00
|
|
|
// or equivalently using "" as a positional command-line argument would be the same as
|
|
|
|
// --empty. This probably isn't worth blocking or coding around.
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::Config::outputFile(std::string const& filename)
|
2022-01-26 18:56:13 +00:00
|
|
|
{
|
2022-07-26 11:37:50 +00:00
|
|
|
if ((o.m->outfilename == nullptr) && (!o.m->replace_input)) {
|
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-07-26 11:37:50 +00:00
|
|
|
if ((o.m->outfilename == nullptr) && (!o.m->replace_input)) {
|
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-02-01 09:16:58 +00:00
|
|
|
QPDFJob::Config*
|
|
|
|
QPDFJob::Config::collate()
|
|
|
|
{
|
2022-02-01 18:37:31 +00:00
|
|
|
return collate("");
|
2022-02-01 09:16:58 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-02-01 18:37:31 +00:00
|
|
|
QPDFJob::Config::collate(std::string const& parameter)
|
2022-01-24 00:46:20 +00:00
|
|
|
{
|
2024-01-01 23:55:45 +00:00
|
|
|
if (parameter.empty()) {
|
|
|
|
o.m->collate.push_back(1);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
size_t pos = 0;
|
|
|
|
// Parse a,b,c
|
|
|
|
while (true) {
|
|
|
|
auto end = parameter.find(',', pos);
|
|
|
|
auto n = parameter.substr(pos, end);
|
|
|
|
if (n.empty()) {
|
|
|
|
usage("--collate: trailing comma");
|
|
|
|
}
|
|
|
|
o.m->collate.push_back(QIntC::to_size(QUtil::string_to_uint(n.c_str())));
|
|
|
|
if (end == std::string::npos) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pos = end + 1;
|
|
|
|
}
|
|
|
|
if (o.m->collate.empty()) {
|
|
|
|
o.m->collate.push_back(1);
|
|
|
|
}
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::Config::compressStreams(std::string const& parameter)
|
2022-01-24 00:46:20 +00:00
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->compress_streams_set = true;
|
2022-02-01 18:37:31 +00:00
|
|
|
o.m->compress_streams = (parameter == "y");
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::Config::compressionLevel(std::string const& parameter)
|
2022-01-24 00:46:20 +00:00
|
|
|
{
|
2022-02-01 18:37:31 +00:00
|
|
|
o.m->compression_level = QUtil::string_to_int(parameter.c_str());
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::Config::copyEncryption(std::string const& parameter)
|
2022-01-24 00:46:20 +00:00
|
|
|
{
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::Config::encryptionFilePassword(std::string const& parameter)
|
2022-01-24 00:46:20 +00:00
|
|
|
{
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::Config::flattenAnnotations(std::string const& parameter)
|
2022-01-24 00:46:20 +00:00
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->flatten_annotations = true;
|
2022-02-01 18:37:31 +00:00
|
|
|
if (parameter == "screen") {
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->flatten_annotations_forbidden |= an_no_view;
|
2022-02-01 18:37:31 +00:00
|
|
|
} else if (parameter == "print") {
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->flatten_annotations_required |= an_print;
|
2022-02-01 18:37:31 +00:00
|
|
|
} else if (parameter != "all") {
|
|
|
|
usage("invalid flatten-annotations option");
|
|
|
|
}
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::Config::forceVersion(std::string const& parameter)
|
2022-01-24 00:46:20 +00:00
|
|
|
{
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::Config::iiMinBytes(std::string const& parameter)
|
2022-01-24 00:46:20 +00:00
|
|
|
{
|
2022-02-01 18:37:31 +00:00
|
|
|
o.m->ii_min_bytes = QUtil::string_to_uint(parameter.c_str());
|
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-02-01 09:16:58 +00:00
|
|
|
QPDFJob::Config*
|
|
|
|
QPDFJob::Config::json()
|
|
|
|
{
|
2022-02-01 18:37:31 +00:00
|
|
|
return json("");
|
2022-02-01 09:16:58 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-02-01 18:37:31 +00:00
|
|
|
QPDFJob::Config::json(std::string const& parameter)
|
2022-01-24 00:46:20 +00:00
|
|
|
{
|
2022-04-16 16:57:33 +00:00
|
|
|
if (parameter.empty() || (parameter == "latest")) {
|
2022-05-07 11:53:45 +00:00
|
|
|
o.m->json_version = JSON::LATEST;
|
2022-02-01 18:37:31 +00:00
|
|
|
} else {
|
|
|
|
o.m->json_version = QUtil::string_to_int(parameter.c_str());
|
|
|
|
}
|
2022-05-07 11:53:45 +00:00
|
|
|
if ((o.m->json_version < 1) || (o.m->json_version > JSON::LATEST)) {
|
2022-01-31 19:20:06 +00:00
|
|
|
usage(std::string("unsupported json 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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::Config::jsonKey(std::string const& parameter)
|
2022-01-24 00:46:20 +00:00
|
|
|
{
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::Config::jsonObject(std::string const& parameter)
|
2022-01-24 00:46:20 +00:00
|
|
|
{
|
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-05-07 17:33:45 +00:00
|
|
|
QPDFJob::Config*
|
|
|
|
QPDFJob::Config::jsonStreamData(std::string const& parameter)
|
|
|
|
{
|
2022-05-18 22:22:57 +00:00
|
|
|
o.m->json_stream_data_set = true;
|
2022-05-07 17:33:45 +00:00
|
|
|
if (parameter == "none") {
|
|
|
|
o.m->json_stream_data = qpdf_sj_none;
|
|
|
|
} else if (parameter == "inline") {
|
|
|
|
o.m->json_stream_data = qpdf_sj_inline;
|
|
|
|
} else if (parameter == "file") {
|
|
|
|
o.m->json_stream_data = qpdf_sj_file;
|
|
|
|
} else {
|
|
|
|
usage("invalid json-streams option");
|
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
QPDFJob::Config*
|
|
|
|
QPDFJob::Config::jsonStreamPrefix(std::string const& parameter)
|
|
|
|
{
|
|
|
|
o.m->json_stream_prefix = parameter;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2022-05-07 21:17:27 +00:00
|
|
|
QPDFJob::Config*
|
2022-05-18 22:22:57 +00:00
|
|
|
QPDFJob::Config::jsonInput()
|
2022-05-07 21:17:27 +00:00
|
|
|
{
|
2022-05-18 22:22:57 +00:00
|
|
|
o.m->json_input = true;
|
2022-05-07 21:17:27 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2022-05-08 17:42:16 +00:00
|
|
|
QPDFJob::Config*
|
2022-05-18 22:22:57 +00:00
|
|
|
QPDFJob::Config::jsonOutput(std::string const& parameter)
|
2022-05-08 17:42:16 +00:00
|
|
|
{
|
2022-07-31 00:53:30 +00:00
|
|
|
o.m->json_output = true;
|
2022-07-31 14:34:05 +00:00
|
|
|
json(parameter);
|
2022-05-18 22:22:57 +00:00
|
|
|
if (!o.m->json_stream_data_set) {
|
|
|
|
// No need to set json_stream_data_set -- that indicates explicit use of --json-stream-data.
|
|
|
|
o.m->json_stream_data = qpdf_sj_inline;
|
|
|
|
}
|
2022-05-21 21:51:34 +00:00
|
|
|
if (!o.m->decode_level_set) {
|
|
|
|
o.m->decode_level = qpdf_dl_none;
|
|
|
|
}
|
2022-07-31 14:34:05 +00:00
|
|
|
o.m->json_keys.insert("qpdf");
|
2022-05-08 17:42:16 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
QPDFJob::Config*
|
|
|
|
QPDFJob::Config::updateFromJson(std::string const& parameter)
|
|
|
|
{
|
|
|
|
o.m->update_from_json = parameter;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2022-05-06 21:29:22 +00:00
|
|
|
QPDFJob::Config*
|
|
|
|
QPDFJob::Config::testJsonSchema()
|
|
|
|
{
|
|
|
|
o.m->test_json_schema = true;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-02-01 18:37:31 +00:00
|
|
|
QPDFJob::Config::keepFilesOpen(std::string const& parameter)
|
2022-01-24 00:46:20 +00:00
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->keep_files_open_set = true;
|
2022-02-01 18:37:31 +00:00
|
|
|
o.m->keep_files_open = (parameter == "y");
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::Config::keepFilesOpenThreshold(std::string const& parameter)
|
2022-01-24 00:46:20 +00:00
|
|
|
{
|
2022-02-01 18:37:31 +00:00
|
|
|
o.m->keep_files_open_threshold = QUtil::string_to_uint(parameter.c_str());
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::Config::linearizePass1(std::string const& parameter)
|
2022-01-24 00:46:20 +00:00
|
|
|
{
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::Config::minVersion(std::string const& parameter)
|
2022-01-24 00:46:20 +00:00
|
|
|
{
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::Config::normalizeContent(std::string const& parameter)
|
2022-01-24 00:46:20 +00:00
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->normalize_set = true;
|
2022-02-01 18:37:31 +00:00
|
|
|
o.m->normalize = (parameter == "y");
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::Config::oiMinArea(std::string const& parameter)
|
2022-01-24 00:46:20 +00:00
|
|
|
{
|
2022-02-01 18:37:31 +00:00
|
|
|
o.m->oi_min_area = QUtil::string_to_uint(parameter.c_str());
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::Config::oiMinHeight(std::string const& parameter)
|
2022-01-24 00:46:20 +00:00
|
|
|
{
|
2022-02-01 18:37:31 +00:00
|
|
|
o.m->oi_min_height = QUtil::string_to_uint(parameter.c_str());
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::Config::oiMinWidth(std::string const& parameter)
|
2022-01-24 00:46:20 +00:00
|
|
|
{
|
2022-02-01 18:37:31 +00:00
|
|
|
o.m->oi_min_width = QUtil::string_to_uint(parameter.c_str());
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::Config::password(std::string const& parameter)
|
2022-01-25 16:14:43 +00:00
|
|
|
{
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::Config::removeAttachment(std::string const& parameter)
|
2022-01-24 00:46:20 +00:00
|
|
|
{
|
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-08-31 17:51:58 +00:00
|
|
|
QPDFJob::Config*
|
2022-09-01 20:40:06 +00:00
|
|
|
QPDFJob::Config::reportMemoryUsage()
|
2022-08-31 17:51:58 +00:00
|
|
|
{
|
|
|
|
o.m->report_mem_usage = true;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
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;
|
2023-01-28 18:24:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QPDFJob::Config*
|
|
|
|
QPDFJob::Config::removeRestrictions()
|
|
|
|
{
|
|
|
|
o.m->remove_restrictions = true;
|
|
|
|
return this;
|
2022-01-24 00:46:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-02-01 18:37:31 +00:00
|
|
|
QPDFJob::Config::showAttachment(std::string const& parameter)
|
2022-01-24 00:46:20 +00:00
|
|
|
{
|
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-02-01 09:16:58 +00:00
|
|
|
QPDFJob::Config*
|
|
|
|
QPDFJob::Config::splitPages()
|
|
|
|
{
|
2022-02-01 18:37:31 +00:00
|
|
|
return splitPages("");
|
2022-02-01 09:16:58 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::Config*
|
2022-02-01 18:37:31 +00:00
|
|
|
QPDFJob::Config::splitPages(std::string const& parameter)
|
2022-01-24 00:46:20 +00:00
|
|
|
{
|
2022-02-01 18:37:31 +00:00
|
|
|
int n = (parameter.empty() ? 1 : QUtil::string_to_int(parameter.c_str()));
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::Config::passwordFile(std::string const& parameter)
|
2022-01-26 00:21:46 +00:00
|
|
|
{
|
|
|
|
std::list<std::string> lines;
|
2022-02-01 18:37:31 +00:00
|
|
|
if (parameter == "-") {
|
2022-01-26 00:21:46 +00:00
|
|
|
QTC::TC("qpdf", "QPDFJob_config password stdin");
|
|
|
|
lines = QUtil::read_lines_from_file(std::cin);
|
|
|
|
} else {
|
|
|
|
QTC::TC("qpdf", "QPDFJob_config password file");
|
2022-02-01 18:37:31 +00:00
|
|
|
lines = QUtil::read_lines_from_file(parameter.c_str());
|
2022-01-26 00:21:46 +00:00
|
|
|
}
|
|
|
|
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) {
|
2022-06-18 14:33:27 +00:00
|
|
|
*QPDFLogger::defaultLogger()->getError()
|
|
|
|
<< this->o.m->message_prefix << ": WARNING: all but the first line of"
|
|
|
|
<< " the password file are ignored\n";
|
2022-01-26 00:21:46 +00:00
|
|
|
}
|
|
|
|
}
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::Config::passwordMode(std::string const& parameter)
|
2022-01-26 00:21:46 +00:00
|
|
|
{
|
2022-02-01 18:37:31 +00:00
|
|
|
if (parameter == "bytes") {
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->password_mode = QPDFJob::pm_bytes;
|
2022-02-01 18:37:31 +00:00
|
|
|
} else if (parameter == "hex-bytes") {
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->password_mode = QPDFJob::pm_hex_bytes;
|
2022-02-01 18:37:31 +00:00
|
|
|
} else if (parameter == "unicode") {
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->password_mode = QPDFJob::pm_unicode;
|
2022-02-01 18:37:31 +00:00
|
|
|
} else if (parameter == "auto") {
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::Config::streamData(std::string const& parameter)
|
2022-01-26 00:21:46 +00:00
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->stream_data_set = true;
|
2022-02-01 18:37:31 +00:00
|
|
|
if (parameter == "compress") {
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->stream_data_mode = qpdf_s_compress;
|
2022-02-01 18:37:31 +00:00
|
|
|
} else if (parameter == "preserve") {
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->stream_data_mode = qpdf_s_preserve;
|
2022-02-01 18:37:31 +00:00
|
|
|
} else if (parameter == "uncompress") {
|
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 {
|
|
|
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::Config::decodeLevel(std::string const& parameter)
|
2022-01-26 00:21:46 +00:00
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->decode_level_set = true;
|
2022-02-01 18:37:31 +00:00
|
|
|
if (parameter == "none") {
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->decode_level = qpdf_dl_none;
|
2022-02-01 18:37:31 +00:00
|
|
|
} else if (parameter == "generalized") {
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->decode_level = qpdf_dl_generalized;
|
2022-02-01 18:37:31 +00:00
|
|
|
} else if (parameter == "specialized") {
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->decode_level = qpdf_dl_specialized;
|
2022-02-01 18:37:31 +00:00
|
|
|
} else if (parameter == "all") {
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->decode_level = qpdf_dl_all;
|
2022-01-26 00:21:46 +00:00
|
|
|
} else {
|
|
|
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::Config::objectStreams(std::string const& parameter)
|
2022-01-26 00:21:46 +00:00
|
|
|
{
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->object_stream_set = true;
|
2022-02-01 18:37:31 +00:00
|
|
|
if (parameter == "disable") {
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->object_stream_mode = qpdf_o_disable;
|
2022-02-01 18:37:31 +00:00
|
|
|
} else if (parameter == "preserve") {
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->object_stream_mode = qpdf_o_preserve;
|
2022-02-01 18:37:31 +00:00
|
|
|
} else if (parameter == "generate") {
|
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 {
|
|
|
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::Config::removeUnreferencedResources(std::string const& parameter)
|
2022-01-26 00:21:46 +00:00
|
|
|
{
|
2022-02-01 18:37:31 +00:00
|
|
|
if (parameter == "auto") {
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->remove_unreferenced_page_resources = QPDFJob::re_auto;
|
2022-02-01 18:37:31 +00:00
|
|
|
} else if (parameter == "yes") {
|
2022-01-26 19:56:24 +00:00
|
|
|
o.m->remove_unreferenced_page_resources = QPDFJob::re_yes;
|
2022-02-01 18:37:31 +00:00
|
|
|
} else if (parameter == "no") {
|
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 {
|
|
|
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::Config::showObject(std::string const& parameter)
|
2022-01-26 00:21:46 +00:00
|
|
|
{
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::Config::jobJsonFile(std::string const& parameter)
|
2022-01-26 00:21:46 +00:00
|
|
|
{
|
|
|
|
try {
|
2023-03-06 14:41:43 +00:00
|
|
|
o.initializeFromJson(QUtil::read_file_into_string(parameter.c_str()), true);
|
2022-01-26 00:21:46 +00:00
|
|
|
} catch (std::exception& e) {
|
|
|
|
throw std::runtime_error(
|
2022-01-29 17:53:35 +00:00
|
|
|
"error with job-json file " + std::string(parameter) + ": " + e.what() + "\nRun " +
|
2022-04-10 19:02:56 +00:00
|
|
|
this->o.m->message_prefix + " --job-json-help for information on the file format.");
|
2022-01-26 00:21:46 +00:00
|
|
|
}
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::Config::rotate(std::string const& parameter)
|
2022-01-26 14:38:34 +00:00
|
|
|
{
|
|
|
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::CopyAttConfig::file(std::string 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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::CopyAttConfig::prefix(std::string const& parameter)
|
2022-01-25 16:07:53 +00:00
|
|
|
{
|
|
|
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::CopyAttConfig::password(std::string const& parameter)
|
2022-01-25 16:07:53 +00:00
|
|
|
{
|
|
|
|
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-31 18:07:19 +00:00
|
|
|
usage("copy attachments: no file 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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::AttConfig::file(std::string const& parameter)
|
2022-01-25 21:37:17 +00:00
|
|
|
{
|
|
|
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::AttConfig::key(std::string const& parameter)
|
2022-01-25 21:37:17 +00:00
|
|
|
{
|
|
|
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::AttConfig::filename(std::string const& parameter)
|
2022-01-25 21:37:17 +00:00
|
|
|
{
|
|
|
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::AttConfig::creationdate(std::string const& parameter)
|
2022-01-25 21:37:17 +00:00
|
|
|
{
|
|
|
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::AttConfig::moddate(std::string const& parameter)
|
2022-01-25 21:37:17 +00:00
|
|
|
{
|
|
|
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::AttConfig::mimetype(std::string const& parameter)
|
2022-01-25 21:37:17 +00:00
|
|
|
{
|
2022-02-01 18:37:31 +00:00
|
|
|
if (parameter.find('/') == std::string::npos) {
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::AttConfig::description(std::string const& parameter)
|
2022-01-25 21:37:17 +00:00
|
|
|
{
|
|
|
|
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-31 18:07:19 +00:00
|
|
|
usage("add attachment: no file 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-31 18:07:19 +00:00
|
|
|
usage("file 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
|
|
|
{
|
2024-01-01 23:55:45 +00:00
|
|
|
auto n_specs = config->o.m->page_specs.size();
|
|
|
|
if (n_specs == 0) {
|
2022-01-26 00:21:46 +00:00
|
|
|
usage("--pages: no page specifications given");
|
2022-01-26 00:01:10 +00:00
|
|
|
}
|
2024-01-01 23:55:45 +00:00
|
|
|
auto n_collate = config->o.m->collate.size();
|
|
|
|
if (!(n_collate == 0 || n_collate == 1 || n_collate == n_specs)) {
|
|
|
|
usage("--pages: if --collate has more than one value, it must have one value per page "
|
|
|
|
"specification");
|
|
|
|
}
|
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, std::string const& range, char const* password)
|
|
|
|
{
|
2023-05-27 22:49:18 +00:00
|
|
|
this->config->o.m->page_specs.emplace_back(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()) {
|
|
|
|
usage(config->o.m->under_overlay->which + " file not specified");
|
2022-01-26 14:38:34 +00:00
|
|
|
}
|
2022-07-26 11:37:50 +00:00
|
|
|
config->o.m->under_overlay = nullptr;
|
2022-01-26 14:38:34 +00:00
|
|
|
return this->config;
|
|
|
|
}
|
|
|
|
|
2022-01-26 22:18:03 +00:00
|
|
|
QPDFJob::UOConfig*
|
2022-02-01 18:37:31 +00:00
|
|
|
QPDFJob::UOConfig::file(std::string const& parameter)
|
2022-01-26 14:38:34 +00:00
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
if (!config->o.m->under_overlay->filename.empty()) {
|
|
|
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::UOConfig::to(std::string const& parameter)
|
2022-01-26 14:38:34 +00:00
|
|
|
{
|
2022-02-01 18:37:31 +00:00
|
|
|
config->o.parseNumrange(parameter.c_str(), 0);
|
2022-01-26 22:18:03 +00:00
|
|
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::UOConfig::from(std::string const& parameter)
|
2022-01-26 14:38:34 +00:00
|
|
|
{
|
2022-02-01 18:37:31 +00:00
|
|
|
if (!parameter.empty()) {
|
|
|
|
config->o.parseNumrange(parameter.c_str(), 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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::UOConfig::repeat(std::string const& parameter)
|
2022-01-26 14:38:34 +00:00
|
|
|
{
|
2022-02-01 18:37:31 +00:00
|
|
|
if (!parameter.empty()) {
|
|
|
|
config->o.parseNumrange(parameter.c_str(), 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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::UOConfig::password(std::string const& parameter)
|
2022-01-26 14:38:34 +00:00
|
|
|
{
|
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
|
|
|
{
|
2023-12-23 01:09:31 +00:00
|
|
|
if (config->o.m->keylen == 0) {
|
|
|
|
usage("encryption key length is required");
|
|
|
|
}
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::EncConfig::accessibility(std::string const& parameter)
|
2022-01-26 18:17:57 +00:00
|
|
|
{
|
2022-02-01 18:37:31 +00:00
|
|
|
config->o.m->r3_accessibility = (parameter == "y");
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::EncConfig::extract(std::string const& parameter)
|
2022-01-26 18:17:57 +00:00
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
if (config->o.m->keylen == 40) {
|
2022-02-01 18:37:31 +00:00
|
|
|
config->o.m->r2_extract = (parameter == "y");
|
2022-01-26 18:17:57 +00:00
|
|
|
} else {
|
2022-02-01 18:37:31 +00:00
|
|
|
config->o.m->r3_extract = (parameter == "y");
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::EncConfig::print(std::string const& parameter)
|
2022-01-26 18:17:57 +00:00
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
if (config->o.m->keylen == 40) {
|
2022-02-01 18:37:31 +00:00
|
|
|
config->o.m->r2_print = (parameter == "y");
|
|
|
|
} else if (parameter == "full") {
|
2022-01-26 22:18:03 +00:00
|
|
|
config->o.m->r3_print = qpdf_r3p_full;
|
2022-02-01 18:37:31 +00:00
|
|
|
} else if (parameter == "low") {
|
2022-01-26 22:18:03 +00:00
|
|
|
config->o.m->r3_print = qpdf_r3p_low;
|
2022-02-01 18:37:31 +00:00
|
|
|
} else if (parameter == "none") {
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::EncConfig::modify(std::string const& parameter)
|
2022-01-26 18:17:57 +00:00
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
if (config->o.m->keylen == 40) {
|
2022-02-01 18:37:31 +00:00
|
|
|
config->o.m->r2_modify = (parameter == "y");
|
|
|
|
} else if (parameter == "all") {
|
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-02-01 18:37:31 +00:00
|
|
|
} else if (parameter == "annotate") {
|
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-02-01 18:37:31 +00:00
|
|
|
} else if (parameter == "form") {
|
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-02-01 18:37:31 +00:00
|
|
|
} else if (parameter == "assembly") {
|
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-02-01 18:37:31 +00:00
|
|
|
} else if (parameter == "none") {
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::EncConfig::assemble(std::string const& parameter)
|
2022-01-26 18:17:57 +00:00
|
|
|
{
|
2022-02-01 18:37:31 +00:00
|
|
|
config->o.m->r3_assemble = (parameter == "y");
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::EncConfig::annotate(std::string const& parameter)
|
2022-01-26 18:17:57 +00:00
|
|
|
{
|
2022-01-26 22:18:03 +00:00
|
|
|
if (config->o.m->keylen == 40) {
|
2022-02-01 18:37:31 +00:00
|
|
|
config->o.m->r2_annotate = (parameter == "y");
|
2022-01-26 18:17:57 +00:00
|
|
|
} else {
|
2022-02-01 18:37:31 +00:00
|
|
|
config->o.m->r3_annotate_and_form = (parameter == "y");
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::EncConfig::form(std::string const& parameter)
|
2022-01-26 18:17:57 +00:00
|
|
|
{
|
2022-02-01 18:37:31 +00:00
|
|
|
config->o.m->r3_form_filling = (parameter == "y");
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::EncConfig::modifyOther(std::string const& parameter)
|
2022-01-26 18:17:57 +00:00
|
|
|
{
|
2022-02-01 18:37:31 +00:00
|
|
|
config->o.m->r3_modify_other = (parameter == "y");
|
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-02-01 18:37:31 +00:00
|
|
|
QPDFJob::EncConfig::useAes(std::string const& parameter)
|
2022-01-26 18:17:57 +00:00
|
|
|
{
|
2022-02-01 18:37:31 +00:00
|
|
|
config->o.m->use_aes = (parameter == "y");
|
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::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
|
|
|
}
|