2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-22 19:08:59 +00:00

QPDFJob: incorporate change to JSONHandler for dict start function

This commit is contained in:
Jay Berkenbilt 2022-01-30 08:04:45 -05:00
parent ce3406e93f
commit e01bbccb40
7 changed files with 124 additions and 115 deletions

View File

@ -516,11 +516,11 @@ class Main:
def build_schema(j, s, flag, path): def build_schema(j, s, flag, path):
if flag: if flag:
identifier = self.to_identifier(path, '', False) identifier = self.to_identifier(path, '', False)
self.json_decls.append(f'void begin{identifier}();') self.json_decls.append(f'void begin{identifier}(JSON);')
self.json_decls.append(f'void end{identifier}();') self.json_decls.append(f'void end{identifier}();')
self.json_init.append( self.json_init.append(
f'beginDict("{flag}",' f'beginDict("{flag}",'
f' bindBare(&Handlers::begin{identifier}),' f' bindJSON(&Handlers::begin{identifier}),'
f' bindBare(&Handlers::end{identifier})); // {path}') f' bindBare(&Handlers::end{identifier})); // {path}')
for k, v in j.items(): for k, v in j.items():
is_trivial = False is_trivial = False

View File

@ -1,17 +1,17 @@
# Generated by generate_auto_job # Generated by generate_auto_job
generate_auto_job 53b2b81e8cb38f1bfa0053f351f37fe9e9437eb2cef808ff0c01cfc56ca20946 generate_auto_job e4a071599697cc0f4d985367735ac6ed6110575e2cbfa01406d048780466d546
include/qpdf/auto_job_c_att.hh 7ad43bb374c1370ef32ebdcdcb7b73a61d281f7f4e3f12755585872ab30fb60e include/qpdf/auto_job_c_att.hh 7ad43bb374c1370ef32ebdcdcb7b73a61d281f7f4e3f12755585872ab30fb60e
include/qpdf/auto_job_c_copy_att.hh 32275d03cdc69b703dd7e02ba0bbe15756e714e9ad185484773a6178dc09e1ee include/qpdf/auto_job_c_copy_att.hh 32275d03cdc69b703dd7e02ba0bbe15756e714e9ad185484773a6178dc09e1ee
include/qpdf/auto_job_c_enc.hh 72e138c7b96ed5aacdce78c1dec04b1c20d361faec4f8faf52f64c1d6be99265 include/qpdf/auto_job_c_enc.hh 72e138c7b96ed5aacdce78c1dec04b1c20d361faec4f8faf52f64c1d6be99265
include/qpdf/auto_job_c_main.hh 516adb23cc7e44e614e436880be870d0574e4ebbc706cd855a1360000eed31bb include/qpdf/auto_job_c_main.hh 516adb23cc7e44e614e436880be870d0574e4ebbc706cd855a1360000eed31bb
include/qpdf/auto_job_c_pages.hh 931840b329a36ca0e41401190e04537b47f2867671a6643bfd8da74014202671 include/qpdf/auto_job_c_pages.hh 931840b329a36ca0e41401190e04537b47f2867671a6643bfd8da74014202671
include/qpdf/auto_job_c_uo.hh 0585b7de459fa479d9e51a45fa92de0ff6dee748efc9ec1cedd0dde6cee1ad50 include/qpdf/auto_job_c_uo.hh 0585b7de459fa479d9e51a45fa92de0ff6dee748efc9ec1cedd0dde6cee1ad50
job.yml d9be74c397e1f272ac6a81981a528c332f8bd7b98d58ae6ba6f60875391567e8 job.yml 7433861fa281197aa275d624a334aa324ec63839c5e56a24448ab64d0b75587c
libqpdf/qpdf/auto_job_decl.hh 9f79396ec459f191be4c5fe34cf88c265cf47355a1a945fa39169d1c94cf04f6 libqpdf/qpdf/auto_job_decl.hh 9f79396ec459f191be4c5fe34cf88c265cf47355a1a945fa39169d1c94cf04f6
libqpdf/qpdf/auto_job_help.hh 23c79f1d2c02bda28f64aace17f69487205c797e7ae2234892cbbabab49d6d47 libqpdf/qpdf/auto_job_help.hh 23c79f1d2c02bda28f64aace17f69487205c797e7ae2234892cbbabab49d6d47
libqpdf/qpdf/auto_job_init.hh 8e9e31b6099a662497339b27f6e2d7f779f35011e88a834bee8811c33405a0fe libqpdf/qpdf/auto_job_init.hh 8e9e31b6099a662497339b27f6e2d7f779f35011e88a834bee8811c33405a0fe
libqpdf/qpdf/auto_job_json_decl.hh d729213332b92ee0da89d1cad0318ab96aec443f37d208fbbc8d56e9d1398ac2 libqpdf/qpdf/auto_job_json_decl.hh d315f920a32d7a5a2272807e6813d463c3e1877a9d735e44e8417b5f1461b87a
libqpdf/qpdf/auto_job_json_init.hh a28c2c2b83d1c0036d3d07172dffb1eac1b75ce3d6a615a87111e9f3bd3dad58 libqpdf/qpdf/auto_job_json_init.hh 08e6ee8a509bc592e3aa6f7a1d3a6d18cdf4803e6220147855caf675e0a299ce
libqpdf/qpdf/auto_job_schema.hh 9962f09f3260c01d4165a6ddf2814a0621395dcb5d80a3d310f580a1b7d3baba libqpdf/qpdf/auto_job_schema.hh 6ec5b9dd3b4709b49fb3b928c4d9cde8b35ad938a0945f81c9a3da6c3bf9a3c1
manual/_ext/qpdf.py e9ac9d6c70642a3d29281ee5ad92ae2422dee8be9306fb8a0bc9dba0ed5e28f3 manual/_ext/qpdf.py e9ac9d6c70642a3d29281ee5ad92ae2422dee8be9306fb8a0bc9dba0ed5e28f3
manual/cli.rst 79140e023faa0cb77afe0b1dc512dd120ee5617f4db82f842596e4f239f93882 manual/cli.rst 79140e023faa0cb77afe0b1dc512dd120ee5617f4db82f842596e4f239f93882

21
job.yml
View File

@ -249,16 +249,20 @@ json:
# QPDFJob looks like. If a key starts with underscore or has a value # QPDFJob looks like. If a key starts with underscore or has a value
# that is a string, it does not map to a command-line argument. If # that is a string, it does not map to a command-line argument. If
# value is null, its properties and help come from other information # value is null, its properties and help come from other information
# known by generate_auto_job. This information is used to construct # known by generate_auto_job. Otherwise, it has to match a
# a "schema" (as in JSON.hh) for the json input to QPDFJob. The # command-line option. This information is used to construct a
# leading underscore is removed. # "schema" (as in JSON.hh) for the json input to QPDFJob. The
# leading underscore is removed. *NOTE*: all keys are converted to
# camelCase for the schema and must be appear that way in the
# user-supplied json. This makes it more convenient to populate JSON
# objects in some languages.
_input: _input:
_fileName: "input filename" _filename: "input filename"
main.password: main.password:
password-file: password-file:
empty: empty:
_output: _output:
_fileName: "output filename" _filename: "output filename"
_replace-input: "set to true to replace input" _replace-input: "set to true to replace input"
_options: _options:
qdf: qdf:
@ -283,15 +287,14 @@ json:
progress: progress:
split-pages: split-pages:
encrypt: encrypt:
key-length: "key length: 48, 128, 256"
user-password: "user password" user-password: "user password"
owner-password: "owner password" owner-password: "owner password"
_40-bit: _40bit:
Enc40.annotate: Enc40.annotate:
Enc40.extract: Enc40.extract:
Enc40.modify: Enc40.modify:
Enc40.print: Enc40.print:
_128-bit: _128bit:
Enc128.accessibility: Enc128.accessibility:
Enc128.annotate: Enc128.annotate:
Enc128.assemble: Enc128.assemble:
@ -303,7 +306,7 @@ json:
Enc128.print: Enc128.print:
force-V4: force-V4:
use-aes: use-aes:
_256-bit: _256bit:
Enc256.accessibility: Enc256.accessibility:
Enc256.annotate: Enc256.annotate:
Enc256.assemble: Enc256.assemble:

View File

@ -1,6 +1,7 @@
#include <qpdf/QPDFJob.hh> #include <qpdf/QPDFJob.hh>
#include <qpdf/JSONHandler.hh> #include <qpdf/JSONHandler.hh>
#include <qpdf/QPDFUsage.hh> #include <qpdf/QPDFUsage.hh>
#include <qpdf/QUtil.hh>
#include <memory> #include <memory>
#include <stdexcept> #include <stdexcept>
@ -25,6 +26,7 @@ namespace
typedef std::function<void()> bare_handler_t; typedef std::function<void()> bare_handler_t;
typedef std::function<void(char const*)> param_handler_t; typedef std::function<void(char const*)> param_handler_t;
typedef std::function<void(JSON)> json_handler_t;
typedef std::function<void(std::string const& key)> setup_handler_t; typedef std::function<void(std::string const& key)> setup_handler_t;
void addBare(std::string const& key, bare_handler_t); void addBare(std::string const& key, bare_handler_t);
@ -33,11 +35,12 @@ namespace
param_handler_t); param_handler_t);
void doSetup(std::string const& key, setup_handler_t); void doSetup(std::string const& key, setup_handler_t);
void beginDict(std::string const& key, void beginDict(std::string const& key,
bare_handler_t start_fn, json_handler_t start_fn,
bare_handler_t end_fn); bare_handler_t end_fn);
void endDict(); void endDict();
bare_handler_t bindBare(void (Handlers::*f)()); bare_handler_t bindBare(void (Handlers::*f)());
json_handler_t bindJSON(void (Handlers::*f)(JSON));
setup_handler_t bindSetup(void (Handlers::*f)(std::string const&)); setup_handler_t bindSetup(void (Handlers::*f)(std::string const&));
std::list<std::shared_ptr<JSONHandler>> json_handlers; std::list<std::shared_ptr<JSONHandler>> json_handlers;
@ -70,6 +73,12 @@ Handlers::bindBare(void (Handlers::*f)())
return std::bind(std::mem_fn(f), this); return std::bind(std::mem_fn(f), this);
} }
Handlers::json_handler_t
Handlers::bindJSON(void (Handlers::*f)(JSON))
{
return std::bind(std::mem_fn(f), this, std::placeholders::_1);
}
Handlers::setup_handler_t Handlers::setup_handler_t
Handlers::bindSetup(void (Handlers::*f)(std::string const&)) Handlers::bindSetup(void (Handlers::*f)(std::string const&))
{ {
@ -82,7 +91,7 @@ Handlers::initHandlers()
this->json_handlers.push_back(std::make_shared<JSONHandler>()); this->json_handlers.push_back(std::make_shared<JSONHandler>());
this->jh = this->json_handlers.back().get(); this->jh = this->json_handlers.back().get();
jh->addDictHandlers( jh->addDictHandlers(
[](std::string const&){}, [](std::string const&, JSON){},
[this](std::string const&){c_main->checkConfiguration();}); [this](std::string const&){c_main->checkConfiguration();});
# include <qpdf/auto_job_json_init.hh> # include <qpdf/auto_job_json_init.hh>
@ -172,12 +181,12 @@ Handlers::doSetup(std::string const& key, setup_handler_t fn)
void void
Handlers::beginDict(std::string const& key, Handlers::beginDict(std::string const& key,
bare_handler_t start_fn, json_handler_t start_fn,
bare_handler_t end_fn) bare_handler_t end_fn)
{ {
auto new_jh = std::make_shared<JSONHandler>(); auto new_jh = std::make_shared<JSONHandler>();
new_jh->addDictHandlers( new_jh->addDictHandlers(
[start_fn](std::string const&){ start_fn(); }, [start_fn](std::string const&, JSON j){ start_fn(j); },
[end_fn](std::string const&){ end_fn(); }); [end_fn](std::string const&){ end_fn(); });
this->jh->addDictKeyHandler(key, new_jh); this->jh->addDictKeyHandler(key, new_jh);
this->json_handlers.push_back(new_jh); this->json_handlers.push_back(new_jh);
@ -198,7 +207,7 @@ Handlers::handle(JSON& j)
} }
void void
Handlers::beginInput() Handlers::beginInput(JSON)
{ {
// nothing needed // nothing needed
} }
@ -210,7 +219,7 @@ Handlers::endInput()
} }
void void
Handlers::setupInputFileName(std::string const& key) Handlers::setupInputFilename(std::string const& key)
{ {
addParameter(key, [this](char const* p) { addParameter(key, [this](char const* p) {
c_main->inputFile(p); c_main->inputFile(p);
@ -232,7 +241,7 @@ Handlers::setupInputEmpty(std::string const& key)
} }
void void
Handlers::beginOutput() Handlers::beginOutput(JSON)
{ {
// nothing needed // nothing needed
} }
@ -244,7 +253,7 @@ Handlers::endOutput()
} }
void void
Handlers::setupOutputFileName(std::string const& key) Handlers::setupOutputFilename(std::string const& key)
{ {
addParameter(key, [this](char const* p) { addParameter(key, [this](char const* p) {
c_main->outputFile(p); c_main->outputFile(p);
@ -260,7 +269,7 @@ Handlers::setupOutputReplaceInput(std::string const& key)
} }
void void
Handlers::beginOutputOptions() Handlers::beginOutputOptions(JSON)
{ {
// nothing needed // nothing needed
} }
@ -272,9 +281,15 @@ Handlers::endOutputOptions()
} }
void void
Handlers::beginOutputOptionsEncrypt() Handlers::beginOutputOptionsEncrypt(JSON)
{ {
// QXXXQ // QXXXQ
// if (this->keylen_seen == 0)
// {
// usage("exactly one of 40bit, 128bit, or 256bit must be given;"
// " an empty dictionary may be supplied for one of them"
// " to set the key length without imposing any restrictions");
// }
} }
void void
@ -283,62 +298,56 @@ Handlers::endOutputOptionsEncrypt()
// QXXXQ // QXXXQ
} }
void
Handlers::setupOutputOptionsEncryptKeyLength(std::string const& key)
{
// QXXXQ
}
void void
Handlers::setupOutputOptionsEncryptUserPassword(std::string const& key) Handlers::setupOutputOptionsEncryptUserPassword(std::string const& key)
{ {
// QXXXQ // Key handled in beginOutputOptionsEncrypt
} }
void void
Handlers::setupOutputOptionsEncryptOwnerPassword(std::string const& key) Handlers::setupOutputOptionsEncryptOwnerPassword(std::string const& key)
{ {
// QXXXQ // Key handled in beginOutputOptionsEncrypt
} }
void void
Handlers::beginOutputOptionsEncrypt40Bit() Handlers::beginOutputOptionsEncrypt40bit(JSON)
{ {
// QXXXQ // nothing needed
} }
void void
Handlers::endOutputOptionsEncrypt40Bit() Handlers::endOutputOptionsEncrypt40bit()
{ {
// QXXXQ // nothing needed
} }
void void
Handlers::beginOutputOptionsEncrypt128Bit() Handlers::beginOutputOptionsEncrypt128bit(JSON)
{ {
// QXXXQ // nothing needed
} }
void void
Handlers::endOutputOptionsEncrypt128Bit() Handlers::endOutputOptionsEncrypt128bit()
{ {
// QXXXQ // nothing needed
} }
void void
Handlers::beginOutputOptionsEncrypt256Bit() Handlers::beginOutputOptionsEncrypt256bit(JSON)
{ {
// QXXXQ // nothing needed
} }
void void
Handlers::endOutputOptionsEncrypt256Bit() Handlers::endOutputOptionsEncrypt256bit()
{ {
// QXXXQ // nothing needed
} }
void void
Handlers::beginOptions() Handlers::beginOptions(JSON)
{ {
// nothing needed // nothing needed
} }
@ -350,7 +359,7 @@ Handlers::endOptions()
} }
void void
Handlers::beginInspect() Handlers::beginInspect(JSON)
{ {
// nothing needed // nothing needed
} }
@ -362,7 +371,7 @@ Handlers::endInspect()
} }
void void
Handlers::beginTransform() Handlers::beginTransform(JSON)
{ {
// nothing needed // nothing needed
} }
@ -374,7 +383,7 @@ Handlers::endTransform()
} }
void void
Handlers::beginModify() Handlers::beginModify(JSON)
{ {
// nothing needed // nothing needed
} }
@ -386,7 +395,7 @@ Handlers::endModify()
} }
void void
Handlers::beginModifyAddAttachment() Handlers::beginModifyAddAttachment(JSON)
{ {
// QXXXQ // QXXXQ
} }
@ -400,11 +409,11 @@ Handlers::endModifyAddAttachment()
void void
Handlers::setupModifyAddAttachmentPath(std::string const& key) Handlers::setupModifyAddAttachmentPath(std::string const& key)
{ {
// QXXXQ // QXXXQ setup
} }
void void
Handlers::beginModifyCopyAttachmentsFrom() Handlers::beginModifyCopyAttachmentsFrom(JSON)
{ {
// QXXXQ // QXXXQ
} }
@ -418,17 +427,17 @@ Handlers::endModifyCopyAttachmentsFrom()
void void
Handlers::setupModifyCopyAttachmentsFromPath(std::string const& key) Handlers::setupModifyCopyAttachmentsFromPath(std::string const& key)
{ {
// QXXXQ // QXXXQ setup
} }
void void
Handlers::setupModifyCopyAttachmentsFromPassword(std::string const& key) Handlers::setupModifyCopyAttachmentsFromPassword(std::string const& key)
{ {
// QXXXQ // QXXXQ setup
} }
void void
Handlers::beginModifyPages() Handlers::beginModifyPages(JSON)
{ {
// QXXXQ // QXXXQ
} }
@ -442,23 +451,23 @@ Handlers::endModifyPages()
void void
Handlers::setupModifyPagesFile(std::string const& key) Handlers::setupModifyPagesFile(std::string const& key)
{ {
// QXXXQ // QXXXQ setup
} }
void void
Handlers::setupModifyPagesPassword(std::string const& key) Handlers::setupModifyPagesPassword(std::string const& key)
{ {
// QXXXQ // QXXXQ setup
} }
void void
Handlers::setupModifyPagesRange(std::string const& key) Handlers::setupModifyPagesRange(std::string const& key)
{ {
// QXXXQ // QXXXQ setup
} }
void void
Handlers::beginModifyOverlay() Handlers::beginModifyOverlay(JSON)
{ {
// QXXXQ // QXXXQ
} }
@ -472,17 +481,17 @@ Handlers::endModifyOverlay()
void void
Handlers::setupModifyOverlayFile(std::string const& key) Handlers::setupModifyOverlayFile(std::string const& key)
{ {
// QXXXQ // QXXXQ setup
} }
void void
Handlers::setupModifyOverlayPassword(std::string const& key) Handlers::setupModifyOverlayPassword(std::string const& key)
{ {
// QXXXQ // QXXXQ setup
} }
void void
Handlers::beginModifyUnderlay() Handlers::beginModifyUnderlay(JSON)
{ {
// QXXXQ // QXXXQ
} }
@ -496,13 +505,13 @@ Handlers::endModifyUnderlay()
void void
Handlers::setupModifyUnderlayFile(std::string const& key) Handlers::setupModifyUnderlayFile(std::string const& key)
{ {
// QXXXQ // QXXXQ setup
} }
void void
Handlers::setupModifyUnderlayPassword(std::string const& key) Handlers::setupModifyUnderlayPassword(std::string const& key)
{ {
// QXXXQ // QXXXQ setup
} }
void void

View File

@ -3,53 +3,52 @@
// Edits will be automatically overwritten if the build is // Edits will be automatically overwritten if the build is
// run in maintainer mode. // run in maintainer mode.
// //
void beginInput(); void beginInput(JSON);
void endInput(); void endInput();
void setupInputFileName(std::string const&); void setupInputFilename(std::string const&);
void setupInputPassword(std::string const&); void setupInputPassword(std::string const&);
void setupInputEmpty(std::string const&); void setupInputEmpty(std::string const&);
void beginOutput(); void beginOutput(JSON);
void endOutput(); void endOutput();
void setupOutputFileName(std::string const&); void setupOutputFilename(std::string const&);
void setupOutputReplaceInput(std::string const&); void setupOutputReplaceInput(std::string const&);
void beginOutputOptions(); void beginOutputOptions(JSON);
void endOutputOptions(); void endOutputOptions();
void beginOutputOptionsEncrypt(); void beginOutputOptionsEncrypt(JSON);
void endOutputOptionsEncrypt(); void endOutputOptionsEncrypt();
void setupOutputOptionsEncryptKeyLength(std::string const&);
void setupOutputOptionsEncryptUserPassword(std::string const&); void setupOutputOptionsEncryptUserPassword(std::string const&);
void setupOutputOptionsEncryptOwnerPassword(std::string const&); void setupOutputOptionsEncryptOwnerPassword(std::string const&);
void beginOutputOptionsEncrypt40Bit(); void beginOutputOptionsEncrypt40bit(JSON);
void endOutputOptionsEncrypt40Bit(); void endOutputOptionsEncrypt40bit();
void beginOutputOptionsEncrypt128Bit(); void beginOutputOptionsEncrypt128bit(JSON);
void endOutputOptionsEncrypt128Bit(); void endOutputOptionsEncrypt128bit();
void beginOutputOptionsEncrypt256Bit(); void beginOutputOptionsEncrypt256bit(JSON);
void endOutputOptionsEncrypt256Bit(); void endOutputOptionsEncrypt256bit();
void beginOptions(); void beginOptions(JSON);
void endOptions(); void endOptions();
void beginInspect(); void beginInspect(JSON);
void endInspect(); void endInspect();
void beginTransform(); void beginTransform(JSON);
void endTransform(); void endTransform();
void beginModify(); void beginModify(JSON);
void endModify(); void endModify();
void beginModifyAddAttachment(); void beginModifyAddAttachment(JSON);
void endModifyAddAttachment(); void endModifyAddAttachment();
void setupModifyAddAttachmentPath(std::string const&); void setupModifyAddAttachmentPath(std::string const&);
void beginModifyCopyAttachmentsFrom(); void beginModifyCopyAttachmentsFrom(JSON);
void endModifyCopyAttachmentsFrom(); void endModifyCopyAttachmentsFrom();
void setupModifyCopyAttachmentsFromPath(std::string const&); void setupModifyCopyAttachmentsFromPath(std::string const&);
void setupModifyCopyAttachmentsFromPassword(std::string const&); void setupModifyCopyAttachmentsFromPassword(std::string const&);
void beginModifyPages(); void beginModifyPages(JSON);
void endModifyPages(); void endModifyPages();
void setupModifyPagesFile(std::string const&); void setupModifyPagesFile(std::string const&);
void setupModifyPagesPassword(std::string const&); void setupModifyPagesPassword(std::string const&);
void setupModifyPagesRange(std::string const&); void setupModifyPagesRange(std::string const&);
void beginModifyOverlay(); void beginModifyOverlay(JSON);
void endModifyOverlay(); void endModifyOverlay();
void setupModifyOverlayFile(std::string const&); void setupModifyOverlayFile(std::string const&);
void setupModifyOverlayPassword(std::string const&); void setupModifyOverlayPassword(std::string const&);
void beginModifyUnderlay(); void beginModifyUnderlay(JSON);
void endModifyUnderlay(); void endModifyUnderlay();
void setupModifyUnderlayFile(std::string const&); void setupModifyUnderlayFile(std::string const&);
void setupModifyUnderlayPassword(std::string const&); void setupModifyUnderlayPassword(std::string const&);

View File

@ -14,16 +14,16 @@ static char const* json_key_choices[] = {"acroform", "attachments", "encrypt", "
static char const* print128_choices[] = {"full", "low", "none", 0}; static char const* print128_choices[] = {"full", "low", "none", 0};
static char const* modify128_choices[] = {"all", "annotate", "form", "assembly", "none", 0}; static char const* modify128_choices[] = {"all", "annotate", "form", "assembly", "none", 0};
beginDict("input", bindBare(&Handlers::beginInput), bindBare(&Handlers::endInput)); // .input beginDict("input", bindJSON(&Handlers::beginInput), bindBare(&Handlers::endInput)); // .input
doSetup("fileName", bindSetup(&Handlers::setupInputFileName)); doSetup("filename", bindSetup(&Handlers::setupInputFilename));
doSetup("password", bindSetup(&Handlers::setupInputPassword)); doSetup("password", bindSetup(&Handlers::setupInputPassword));
addParameter("passwordFile", [this](char const* p) { c_main->passwordFile(p); }); addParameter("passwordFile", [this](char const* p) { c_main->passwordFile(p); });
doSetup("empty", bindSetup(&Handlers::setupInputEmpty)); doSetup("empty", bindSetup(&Handlers::setupInputEmpty));
endDict(); // .input endDict(); // .input
beginDict("output", bindBare(&Handlers::beginOutput), bindBare(&Handlers::endOutput)); // .output beginDict("output", bindJSON(&Handlers::beginOutput), bindBare(&Handlers::endOutput)); // .output
doSetup("fileName", bindSetup(&Handlers::setupOutputFileName)); doSetup("filename", bindSetup(&Handlers::setupOutputFilename));
doSetup("replaceInput", bindSetup(&Handlers::setupOutputReplaceInput)); doSetup("replaceInput", bindSetup(&Handlers::setupOutputReplaceInput));
beginDict("options", bindBare(&Handlers::beginOutputOptions), bindBare(&Handlers::endOutputOptions)); // .output.options beginDict("options", bindJSON(&Handlers::beginOutputOptions), bindBare(&Handlers::endOutputOptions)); // .output.options
addBare("qdf", [this]() { c_main->qdf(); }); addBare("qdf", [this]() { c_main->qdf(); });
addBare("preserveUnreferenced", [this]() { c_main->preserveUnreferenced(); }); addBare("preserveUnreferenced", [this]() { c_main->preserveUnreferenced(); });
addBare("newlineBeforeEndstream", [this]() { c_main->newlineBeforeEndstream(); }); addBare("newlineBeforeEndstream", [this]() { c_main->newlineBeforeEndstream(); });
@ -45,17 +45,16 @@ addParameter("minVersion", [this](char const* p) { c_main->minVersion(p); });
addParameter("forceVersion", [this](char const* p) { c_main->forceVersion(p); }); addParameter("forceVersion", [this](char const* p) { c_main->forceVersion(p); });
addBare("progress", [this]() { c_main->progress(); }); addBare("progress", [this]() { c_main->progress(); });
addParameter("splitPages", [this](char const* p) { c_main->splitPages(p); }); addParameter("splitPages", [this](char const* p) { c_main->splitPages(p); });
beginDict("encrypt", bindBare(&Handlers::beginOutputOptionsEncrypt), bindBare(&Handlers::endOutputOptionsEncrypt)); // .output.options.encrypt beginDict("encrypt", bindJSON(&Handlers::beginOutputOptionsEncrypt), bindBare(&Handlers::endOutputOptionsEncrypt)); // .output.options.encrypt
doSetup("keyLength", bindSetup(&Handlers::setupOutputOptionsEncryptKeyLength));
doSetup("userPassword", bindSetup(&Handlers::setupOutputOptionsEncryptUserPassword)); doSetup("userPassword", bindSetup(&Handlers::setupOutputOptionsEncryptUserPassword));
doSetup("ownerPassword", bindSetup(&Handlers::setupOutputOptionsEncryptOwnerPassword)); doSetup("ownerPassword", bindSetup(&Handlers::setupOutputOptionsEncryptOwnerPassword));
beginDict("40Bit", bindBare(&Handlers::beginOutputOptionsEncrypt40Bit), bindBare(&Handlers::endOutputOptionsEncrypt40Bit)); // .output.options.encrypt.40Bit beginDict("40bit", bindJSON(&Handlers::beginOutputOptionsEncrypt40bit), bindBare(&Handlers::endOutputOptionsEncrypt40bit)); // .output.options.encrypt.40bit
addChoices("annotate", yn_choices, [this](char const* p) { c_enc->annotate(p); }); addChoices("annotate", yn_choices, [this](char const* p) { c_enc->annotate(p); });
addChoices("extract", yn_choices, [this](char const* p) { c_enc->extract(p); }); addChoices("extract", yn_choices, [this](char const* p) { c_enc->extract(p); });
addChoices("modify", modify128_choices, [this](char const* p) { c_enc->modify(p); }); addChoices("modify", modify128_choices, [this](char const* p) { c_enc->modify(p); });
addChoices("print", print128_choices, [this](char const* p) { c_enc->print(p); }); addChoices("print", print128_choices, [this](char const* p) { c_enc->print(p); });
endDict(); // .output.options.encrypt.40Bit endDict(); // .output.options.encrypt.40bit
beginDict("128Bit", bindBare(&Handlers::beginOutputOptionsEncrypt128Bit), bindBare(&Handlers::endOutputOptionsEncrypt128Bit)); // .output.options.encrypt.128Bit beginDict("128bit", bindJSON(&Handlers::beginOutputOptionsEncrypt128bit), bindBare(&Handlers::endOutputOptionsEncrypt128bit)); // .output.options.encrypt.128bit
addChoices("accessibility", yn_choices, [this](char const* p) { c_enc->accessibility(p); }); addChoices("accessibility", yn_choices, [this](char const* p) { c_enc->accessibility(p); });
addChoices("annotate", yn_choices, [this](char const* p) { c_enc->annotate(p); }); addChoices("annotate", yn_choices, [this](char const* p) { c_enc->annotate(p); });
addChoices("assemble", yn_choices, [this](char const* p) { c_enc->assemble(p); }); addChoices("assemble", yn_choices, [this](char const* p) { c_enc->assemble(p); });
@ -67,8 +66,8 @@ addChoices("modify", modify128_choices, [this](char const* p) { c_enc->modify(p)
addChoices("print", print128_choices, [this](char const* p) { c_enc->print(p); }); addChoices("print", print128_choices, [this](char const* p) { c_enc->print(p); });
addBare("forceV4", [this]() { c_enc->forceV4(); }); addBare("forceV4", [this]() { c_enc->forceV4(); });
addChoices("useAes", yn_choices, [this](char const* p) { c_enc->useAes(p); }); addChoices("useAes", yn_choices, [this](char const* p) { c_enc->useAes(p); });
endDict(); // .output.options.encrypt.128Bit endDict(); // .output.options.encrypt.128bit
beginDict("256Bit", bindBare(&Handlers::beginOutputOptionsEncrypt256Bit), bindBare(&Handlers::endOutputOptionsEncrypt256Bit)); // .output.options.encrypt.256Bit beginDict("256bit", bindJSON(&Handlers::beginOutputOptionsEncrypt256bit), bindBare(&Handlers::endOutputOptionsEncrypt256bit)); // .output.options.encrypt.256bit
addChoices("accessibility", yn_choices, [this](char const* p) { c_enc->accessibility(p); }); addChoices("accessibility", yn_choices, [this](char const* p) { c_enc->accessibility(p); });
addChoices("annotate", yn_choices, [this](char const* p) { c_enc->annotate(p); }); addChoices("annotate", yn_choices, [this](char const* p) { c_enc->annotate(p); });
addChoices("assemble", yn_choices, [this](char const* p) { c_enc->assemble(p); }); addChoices("assemble", yn_choices, [this](char const* p) { c_enc->assemble(p); });
@ -80,11 +79,11 @@ addChoices("modify", modify128_choices, [this](char const* p) { c_enc->modify(p)
addChoices("print", print128_choices, [this](char const* p) { c_enc->print(p); }); addChoices("print", print128_choices, [this](char const* p) { c_enc->print(p); });
addBare("allowInsecure", [this]() { c_enc->allowInsecure(); }); addBare("allowInsecure", [this]() { c_enc->allowInsecure(); });
addBare("forceR5", [this]() { c_enc->forceR5(); }); addBare("forceR5", [this]() { c_enc->forceR5(); });
endDict(); // .output.options.encrypt.256Bit endDict(); // .output.options.encrypt.256bit
endDict(); // .output.options.encrypt endDict(); // .output.options.encrypt
endDict(); // .output.options endDict(); // .output.options
endDict(); // .output endDict(); // .output
beginDict("options", bindBare(&Handlers::beginOptions), bindBare(&Handlers::endOptions)); // .options beginDict("options", bindJSON(&Handlers::beginOptions), bindBare(&Handlers::endOptions)); // .options
addBare("allowWeakCrypto", [this]() { c_main->allowWeakCrypto(); }); addBare("allowWeakCrypto", [this]() { c_main->allowWeakCrypto(); });
addBare("deterministicId", [this]() { c_main->deterministicId(); }); addBare("deterministicId", [this]() { c_main->deterministicId(); });
addChoices("keepFilesOpen", yn_choices, [this](char const* p) { c_main->keepFilesOpen(p); }); addChoices("keepFilesOpen", yn_choices, [this](char const* p) { c_main->keepFilesOpen(p); });
@ -98,7 +97,7 @@ addChoices("passwordMode", password_mode_choices, [this](char const* p) { c_main
addBare("suppressPasswordRecovery", [this]() { c_main->suppressPasswordRecovery(); }); addBare("suppressPasswordRecovery", [this]() { c_main->suppressPasswordRecovery(); });
addBare("suppressRecovery", [this]() { c_main->suppressRecovery(); }); addBare("suppressRecovery", [this]() { c_main->suppressRecovery(); });
endDict(); // .options endDict(); // .options
beginDict("inspect", bindBare(&Handlers::beginInspect), bindBare(&Handlers::endInspect)); // .inspect beginDict("inspect", bindJSON(&Handlers::beginInspect), bindBare(&Handlers::endInspect)); // .inspect
addBare("check", [this]() { c_main->check(); }); addBare("check", [this]() { c_main->check(); });
addBare("checkLinearization", [this]() { c_main->checkLinearization(); }); addBare("checkLinearization", [this]() { c_main->checkLinearization(); });
addBare("filteredStreamData", [this]() { c_main->filteredStreamData(); }); addBare("filteredStreamData", [this]() { c_main->filteredStreamData(); });
@ -119,15 +118,15 @@ addBare("json", [this]() { c_main->json(); });
addChoices("jsonKey", json_key_choices, [this](char const* p) { c_main->jsonKey(p); }); addChoices("jsonKey", json_key_choices, [this](char const* p) { c_main->jsonKey(p); });
addParameter("jsonObject", [this](char const* p) { c_main->jsonObject(p); }); addParameter("jsonObject", [this](char const* p) { c_main->jsonObject(p); });
endDict(); // .inspect endDict(); // .inspect
beginDict("transform", bindBare(&Handlers::beginTransform), bindBare(&Handlers::endTransform)); // .transform beginDict("transform", bindJSON(&Handlers::beginTransform), bindBare(&Handlers::endTransform)); // .transform
addBare("coalesceContents", [this]() { c_main->coalesceContents(); }); addBare("coalesceContents", [this]() { c_main->coalesceContents(); });
addParameter("compressionLevel", [this](char const* p) { c_main->compressionLevel(p); }); addParameter("compressionLevel", [this](char const* p) { c_main->compressionLevel(p); });
addBare("externalizeInlineImages", [this]() { c_main->externalizeInlineImages(); }); addBare("externalizeInlineImages", [this]() { c_main->externalizeInlineImages(); });
addParameter("iiMinBytes", [this](char const* p) { c_main->iiMinBytes(p); }); addParameter("iiMinBytes", [this](char const* p) { c_main->iiMinBytes(p); });
addChoices("removeUnreferencedResources", remove_unref_choices, [this](char const* p) { c_main->removeUnreferencedResources(p); }); addChoices("removeUnreferencedResources", remove_unref_choices, [this](char const* p) { c_main->removeUnreferencedResources(p); });
endDict(); // .transform endDict(); // .transform
beginDict("modify", bindBare(&Handlers::beginModify), bindBare(&Handlers::endModify)); // .modify beginDict("modify", bindJSON(&Handlers::beginModify), bindBare(&Handlers::endModify)); // .modify
beginDict("addAttachment", bindBare(&Handlers::beginModifyAddAttachment), bindBare(&Handlers::endModifyAddAttachment)); // .modify.addAttachment beginDict("addAttachment", bindJSON(&Handlers::beginModifyAddAttachment), bindBare(&Handlers::endModifyAddAttachment)); // .modify.addAttachment
doSetup("path", bindSetup(&Handlers::setupModifyAddAttachmentPath)); doSetup("path", bindSetup(&Handlers::setupModifyAddAttachmentPath));
addParameter("creationdate", [this](char const* p) { c_att->creationdate(p); }); addParameter("creationdate", [this](char const* p) { c_att->creationdate(p); });
addParameter("description", [this](char const* p) { c_att->description(p); }); addParameter("description", [this](char const* p) { c_att->description(p); });
@ -138,7 +137,7 @@ addParameter("moddate", [this](char const* p) { c_att->moddate(p); });
addBare("replace", [this]() { c_att->replace(); }); addBare("replace", [this]() { c_att->replace(); });
endDict(); // .modify.addAttachment endDict(); // .modify.addAttachment
addParameter("removeAttachment", [this](char const* p) { c_main->removeAttachment(p); }); addParameter("removeAttachment", [this](char const* p) { c_main->removeAttachment(p); });
beginDict("copyAttachmentsFrom", bindBare(&Handlers::beginModifyCopyAttachmentsFrom), bindBare(&Handlers::endModifyCopyAttachmentsFrom)); // .modify.copyAttachmentsFrom beginDict("copyAttachmentsFrom", bindJSON(&Handlers::beginModifyCopyAttachmentsFrom), bindBare(&Handlers::endModifyCopyAttachmentsFrom)); // .modify.copyAttachmentsFrom
doSetup("path", bindSetup(&Handlers::setupModifyCopyAttachmentsFromPath)); doSetup("path", bindSetup(&Handlers::setupModifyCopyAttachmentsFromPath));
doSetup("password", bindSetup(&Handlers::setupModifyCopyAttachmentsFromPassword)); doSetup("password", bindSetup(&Handlers::setupModifyCopyAttachmentsFromPassword));
addParameter("prefix", [this](char const* p) { c_copy_att->prefix(p); }); addParameter("prefix", [this](char const* p) { c_copy_att->prefix(p); });
@ -152,21 +151,21 @@ addParameter("oiMinArea", [this](char const* p) { c_main->oiMinArea(p); });
addParameter("oiMinHeight", [this](char const* p) { c_main->oiMinHeight(p); }); addParameter("oiMinHeight", [this](char const* p) { c_main->oiMinHeight(p); });
addParameter("oiMinWidth", [this](char const* p) { c_main->oiMinWidth(p); }); addParameter("oiMinWidth", [this](char const* p) { c_main->oiMinWidth(p); });
addBare("optimizeImages", [this]() { c_main->optimizeImages(); }); addBare("optimizeImages", [this]() { c_main->optimizeImages(); });
beginDict("pages", bindBare(&Handlers::beginModifyPages), bindBare(&Handlers::endModifyPages)); // .modify.pages beginDict("pages", bindJSON(&Handlers::beginModifyPages), bindBare(&Handlers::endModifyPages)); // .modify.pages
doSetup("file", bindSetup(&Handlers::setupModifyPagesFile)); doSetup("file", bindSetup(&Handlers::setupModifyPagesFile));
doSetup("password", bindSetup(&Handlers::setupModifyPagesPassword)); doSetup("password", bindSetup(&Handlers::setupModifyPagesPassword));
doSetup("range", bindSetup(&Handlers::setupModifyPagesRange)); doSetup("range", bindSetup(&Handlers::setupModifyPagesRange));
endDict(); // .modify.pages endDict(); // .modify.pages
addBare("removePageLabels", [this]() { c_main->removePageLabels(); }); addBare("removePageLabels", [this]() { c_main->removePageLabels(); });
addParameter("rotate", [this](char const* p) { c_main->rotate(p); }); addParameter("rotate", [this](char const* p) { c_main->rotate(p); });
beginDict("overlay", bindBare(&Handlers::beginModifyOverlay), bindBare(&Handlers::endModifyOverlay)); // .modify.overlay beginDict("overlay", bindJSON(&Handlers::beginModifyOverlay), bindBare(&Handlers::endModifyOverlay)); // .modify.overlay
doSetup("file", bindSetup(&Handlers::setupModifyOverlayFile)); doSetup("file", bindSetup(&Handlers::setupModifyOverlayFile));
doSetup("password", bindSetup(&Handlers::setupModifyOverlayPassword)); doSetup("password", bindSetup(&Handlers::setupModifyOverlayPassword));
addParameter("from", [this](char const* p) { c_uo->from(p); }); addParameter("from", [this](char const* p) { c_uo->from(p); });
addParameter("repeat", [this](char const* p) { c_uo->repeat(p); }); addParameter("repeat", [this](char const* p) { c_uo->repeat(p); });
addParameter("to", [this](char const* p) { c_uo->to(p); }); addParameter("to", [this](char const* p) { c_uo->to(p); });
endDict(); // .modify.overlay endDict(); // .modify.overlay
beginDict("underlay", bindBare(&Handlers::beginModifyUnderlay), bindBare(&Handlers::endModifyUnderlay)); // .modify.underlay beginDict("underlay", bindJSON(&Handlers::beginModifyUnderlay), bindBare(&Handlers::endModifyUnderlay)); // .modify.underlay
doSetup("file", bindSetup(&Handlers::setupModifyUnderlayFile)); doSetup("file", bindSetup(&Handlers::setupModifyUnderlayFile));
doSetup("password", bindSetup(&Handlers::setupModifyUnderlayPassword)); doSetup("password", bindSetup(&Handlers::setupModifyUnderlayPassword));
addParameter("from", [this](char const* p) { c_uo->from(p); }); addParameter("from", [this](char const* p) { c_uo->from(p); });

View File

@ -1,12 +1,12 @@
static constexpr char const* JOB_SCHEMA_DATA = R"({ static constexpr char const* JOB_SCHEMA_DATA = R"({
"input": { "input": {
"fileName": "input filename", "filename": "input filename",
"password": "specify password", "password": "specify password",
"passwordFile": "read password from a file", "passwordFile": "read password from a file",
"empty": "empty input file" "empty": "empty input file"
}, },
"output": { "output": {
"fileName": "output filename", "filename": "output filename",
"replaceInput": "set to true to replace input", "replaceInput": "set to true to replace input",
"options": { "options": {
"qdf": "enable viewing PDF code in a text editor", "qdf": "enable viewing PDF code in a text editor",
@ -31,16 +31,15 @@ static constexpr char const* JOB_SCHEMA_DATA = R"({
"progress": "show progress when writing", "progress": "show progress when writing",
"splitPages": "write pages to separate files", "splitPages": "write pages to separate files",
"encrypt": { "encrypt": {
"keyLength": "key length: 48, 128, 256",
"userPassword": "user password", "userPassword": "user password",
"ownerPassword": "owner password", "ownerPassword": "owner password",
"40Bit": { "40bit": {
"annotate": "restrict document annotation", "annotate": "restrict document annotation",
"extract": "restrict text/graphic extraction", "extract": "restrict text/graphic extraction",
"modify": "restrict document modification", "modify": "restrict document modification",
"print": "restrict printing" "print": "restrict printing"
}, },
"128Bit": { "128bit": {
"accessibility": "restrict document accessibility", "accessibility": "restrict document accessibility",
"annotate": "restrict document annotation", "annotate": "restrict document annotation",
"assemble": "restrict document assembly", "assemble": "restrict document assembly",
@ -53,7 +52,7 @@ static constexpr char const* JOB_SCHEMA_DATA = R"({
"forceV4": "force V=4 in encryption dictionary", "forceV4": "force V=4 in encryption dictionary",
"useAes": "use AES with 128-bit encryption" "useAes": "use AES with 128-bit encryption"
}, },
"256Bit": { "256bit": {
"accessibility": "restrict document accessibility", "accessibility": "restrict document accessibility",
"annotate": "restrict document annotation", "annotate": "restrict document annotation",
"assemble": "restrict document assembly", "assemble": "restrict document assembly",