From ea96330bb615791de58a4f6beb6203137fe1ba35 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Mon, 31 Jan 2022 18:04:14 -0500 Subject: QPDFJob json: flatten json structure Flatten everything to make it easier to map command-line flags to json. The old structure was an illusion anyway because there was no mechanism to enforce that things were in the right place. This also helps with future flexibility. --- libqpdf/QPDFJob_json.cc | 156 ++++++------------- libqpdf/qpdf/auto_job_json_decl.hh | 96 ++++++------ libqpdf/qpdf/auto_job_json_init.hh | 106 ++++++------- libqpdf/qpdf/auto_job_schema.hh | 309 ++++++++++++++++++------------------- 4 files changed, 296 insertions(+), 371 deletions(-) (limited to 'libqpdf') diff --git a/libqpdf/QPDFJob_json.cc b/libqpdf/QPDFJob_json.cc index 2da427c3..3091c7b1 100644 --- a/libqpdf/QPDFJob_json.cc +++ b/libqpdf/QPDFJob_json.cc @@ -219,18 +219,6 @@ Handlers::handle(JSON& j) this->json_handlers.back()->handle(".", j); } -void -Handlers::beginInput(JSON) -{ - // nothing needed -} - -void -Handlers::endInput() -{ - // nothing needed -} - void Handlers::setupInputFile() { @@ -240,7 +228,7 @@ Handlers::setupInputFile() } void -Handlers::setupInputPassword() +Handlers::setupPassword() { addParameter([this](char const* p) { c_main->password(p); @@ -248,25 +236,13 @@ Handlers::setupInputPassword() } void -Handlers::setupInputEmpty() +Handlers::setupEmpty() { addBare([this]() { c_main->emptyInput(); }); } -void -Handlers::beginOutput(JSON) -{ - // nothing needed -} - -void -Handlers::endOutput() -{ - // nothing needed -} - void Handlers::setupOutputFile() { @@ -276,7 +252,7 @@ Handlers::setupOutputFile() } void -Handlers::setupOutputReplaceInput() +Handlers::setupReplaceInput() { addBare([this]() { c_main->replaceInput(); @@ -284,19 +260,7 @@ Handlers::setupOutputReplaceInput() } void -Handlers::beginOutputOptions(JSON) -{ - // nothing needed -} - -void -Handlers::endOutputOptions() -{ - // nothing needed -} - -void -Handlers::beginOutputOptionsEncrypt(JSON j) +Handlers::beginEncrypt(JSON j) { // This method is only called if the overall JSON structure // matches the schema, so we already know that keys that are @@ -342,137 +306,113 @@ Handlers::beginOutputOptionsEncrypt(JSON j) } void -Handlers::endOutputOptionsEncrypt() +Handlers::endEncrypt() { this->c_enc->endEncrypt(); this->c_enc = nullptr; } void -Handlers::setupOutputOptionsEncryptUserPassword() +Handlers::setupEncryptUserPassword() { - // handled in beginOutputOptionsEncrypt + // handled in beginEncrypt ignoreItem(); } void -Handlers::setupOutputOptionsEncryptOwnerPassword() +Handlers::setupEncryptOwnerPassword() { - // handled in beginOutputOptionsEncrypt + // handled in beginEncrypt ignoreItem(); } void -Handlers::beginOutputOptionsEncrypt40bit(JSON) -{ - // nothing needed -} - -void -Handlers::endOutputOptionsEncrypt40bit() -{ - // nothing needed -} - -void -Handlers::beginOutputOptionsEncrypt128bit(JSON) -{ - // nothing needed -} - -void -Handlers::endOutputOptionsEncrypt128bit() -{ - // nothing needed -} - -void -Handlers::beginOutputOptionsEncrypt256bit(JSON) +Handlers::beginEncrypt40bit(JSON) { // nothing needed } void -Handlers::endOutputOptionsEncrypt256bit() +Handlers::endEncrypt40bit() { // nothing needed } void -Handlers::beginOptions(JSON) +Handlers::beginEncrypt128bit(JSON) { // nothing needed } void -Handlers::endOptions() +Handlers::endEncrypt128bit() { // nothing needed } void -Handlers::beginInspect(JSON) +Handlers::beginEncrypt256bit(JSON) { // nothing needed } void -Handlers::endInspect() +Handlers::endEncrypt256bit() { // nothing needed } void -Handlers::beginInspectJsonKeyArray(JSON) +Handlers::beginJsonKeyArray(JSON) { // nothing needed } void -Handlers::endInspectJsonKeyArray() +Handlers::endJsonKeyArray() { // nothing needed } void -Handlers::beginInspectJsonObjectArray(JSON) +Handlers::beginJsonObjectArray(JSON) { // nothing needed } void -Handlers::endInspectJsonObjectArray() +Handlers::endJsonObjectArray() { // nothing needed } void -Handlers::beginOptionsAddAttachmentArray(JSON) +Handlers::beginAddAttachmentArray(JSON) { // nothing needed } void -Handlers::endOptionsAddAttachmentArray() +Handlers::endAddAttachmentArray() { // nothing needed } void -Handlers::beginOptionsAddAttachment(JSON) +Handlers::beginAddAttachment(JSON) { this->c_att = c_main->addAttachment(); } void -Handlers::endOptionsAddAttachment() +Handlers::endAddAttachment() { this->c_att->endAddAttachment(); this->c_att = nullptr; } void -Handlers::setupOptionsAddAttachmentFile() +Handlers::setupAddAttachmentFile() { addParameter([this](char const* p) { c_att->file(p); @@ -480,32 +420,32 @@ Handlers::setupOptionsAddAttachmentFile() } void -Handlers::beginOptionsCopyAttachmentsFromArray(JSON) +Handlers::beginCopyAttachmentsFromArray(JSON) { // nothing needed } void -Handlers::endOptionsCopyAttachmentsFromArray() +Handlers::endCopyAttachmentsFromArray() { // nothing needed } void -Handlers::beginOptionsCopyAttachmentsFrom(JSON) +Handlers::beginCopyAttachmentsFrom(JSON) { this->c_copy_att = c_main->copyAttachmentsFrom(); } void -Handlers::endOptionsCopyAttachmentsFrom() +Handlers::endCopyAttachmentsFrom() { this->c_copy_att->endCopyAttachmentsFrom(); this->c_copy_att = nullptr; } void -Handlers::setupOptionsCopyAttachmentsFromFile() +Handlers::setupCopyAttachmentsFromFile() { addParameter([this](char const* p) { c_copy_att->file(p); @@ -513,7 +453,7 @@ Handlers::setupOptionsCopyAttachmentsFromFile() } void -Handlers::setupOptionsCopyAttachmentsFromPassword() +Handlers::setupCopyAttachmentsFromPassword() { addParameter([this](char const* p) { c_copy_att->password(p); @@ -521,20 +461,20 @@ Handlers::setupOptionsCopyAttachmentsFromPassword() } void -Handlers::beginOptionsPagesArray(JSON) +Handlers::beginPagesArray(JSON) { this->c_pages = c_main->pages(); } void -Handlers::endOptionsPagesArray() +Handlers::endPagesArray() { c_pages->endPages(); c_pages = nullptr; } void -Handlers::beginOptionsPages(JSON j) +Handlers::beginPages(JSON j) { std::string file; std::string range("1-z"); @@ -565,47 +505,47 @@ Handlers::beginOptionsPages(JSON j) } void -Handlers::endOptionsPages() +Handlers::endPages() { // nothing needed } void -Handlers::setupOptionsPagesFile() +Handlers::setupPagesFile() { - // handled in beginOptionsPages + // handled in beginPages ignoreItem(); } void -Handlers::setupOptionsPagesPassword() +Handlers::setupPagesPassword() { - // handled in beginOptionsPages + // handled in beginPages ignoreItem(); } void -Handlers::setupOptionsPagesRange() +Handlers::setupPagesRange() { - // handled in beginOptionsPages + // handled in beginPages ignoreItem(); } void -Handlers::beginOptionsOverlay(JSON) +Handlers::beginOverlay(JSON) { this->c_uo = c_main->overlay(); } void -Handlers::endOptionsOverlay() +Handlers::endOverlay() { c_uo->endUnderlayOverlay(); c_uo = nullptr; } void -Handlers::setupOptionsOverlayFile() +Handlers::setupOverlayFile() { addParameter([this](char const* p) { c_uo->file(p); @@ -613,7 +553,7 @@ Handlers::setupOptionsOverlayFile() } void -Handlers::setupOptionsOverlayPassword() +Handlers::setupOverlayPassword() { addParameter([this](char const* p) { c_uo->password(p); @@ -621,20 +561,20 @@ Handlers::setupOptionsOverlayPassword() } void -Handlers::beginOptionsUnderlay(JSON) +Handlers::beginUnderlay(JSON) { this->c_uo = c_main->underlay(); } void -Handlers::endOptionsUnderlay() +Handlers::endUnderlay() { c_uo->endUnderlayOverlay(); c_uo = nullptr; } void -Handlers::setupOptionsUnderlayFile() +Handlers::setupUnderlayFile() { addParameter([this](char const* p) { c_uo->file(p); @@ -642,7 +582,7 @@ Handlers::setupOptionsUnderlayFile() } void -Handlers::setupOptionsUnderlayPassword() +Handlers::setupUnderlayPassword() { addParameter([this](char const* p) { c_uo->password(p); diff --git a/libqpdf/qpdf/auto_job_json_decl.hh b/libqpdf/qpdf/auto_job_json_decl.hh index ba9b7029..951e6a92 100644 --- a/libqpdf/qpdf/auto_job_json_decl.hh +++ b/libqpdf/qpdf/auto_job_json_decl.hh @@ -3,58 +3,48 @@ // Edits will be automatically overwritten if the build is // run in maintainer mode. // -void beginInput(JSON); -void endInput(); void setupInputFile(); -void setupInputPassword(); -void setupInputEmpty(); -void beginOutput(JSON); -void endOutput(); +void setupPassword(); +void setupEmpty(); void setupOutputFile(); -void setupOutputReplaceInput(); -void beginOutputOptions(JSON); -void endOutputOptions(); -void beginOutputOptionsEncrypt(JSON); -void endOutputOptionsEncrypt(); -void setupOutputOptionsEncryptUserPassword(); -void setupOutputOptionsEncryptOwnerPassword(); -void beginOutputOptionsEncrypt40bit(JSON); -void endOutputOptionsEncrypt40bit(); -void beginOutputOptionsEncrypt128bit(JSON); -void endOutputOptionsEncrypt128bit(); -void beginOutputOptionsEncrypt256bit(JSON); -void endOutputOptionsEncrypt256bit(); -void beginInspect(JSON); -void endInspect(); -void beginInspectJsonKeyArray(JSON); -void endInspectJsonKeyArray(); -void beginInspectJsonObjectArray(JSON); -void endInspectJsonObjectArray(); -void beginOptions(JSON); -void endOptions(); -void beginOptionsAddAttachmentArray(JSON); -void endOptionsAddAttachmentArray(); -void beginOptionsAddAttachment(JSON); -void endOptionsAddAttachment(); -void setupOptionsAddAttachmentFile(); -void beginOptionsCopyAttachmentsFromArray(JSON); -void endOptionsCopyAttachmentsFromArray(); -void beginOptionsCopyAttachmentsFrom(JSON); -void endOptionsCopyAttachmentsFrom(); -void setupOptionsCopyAttachmentsFromFile(); -void setupOptionsCopyAttachmentsFromPassword(); -void beginOptionsPagesArray(JSON); -void endOptionsPagesArray(); -void beginOptionsPages(JSON); -void endOptionsPages(); -void setupOptionsPagesFile(); -void setupOptionsPagesPassword(); -void setupOptionsPagesRange(); -void beginOptionsOverlay(JSON); -void endOptionsOverlay(); -void setupOptionsOverlayFile(); -void setupOptionsOverlayPassword(); -void beginOptionsUnderlay(JSON); -void endOptionsUnderlay(); -void setupOptionsUnderlayFile(); -void setupOptionsUnderlayPassword(); +void setupReplaceInput(); +void beginEncrypt(JSON); +void endEncrypt(); +void setupEncryptUserPassword(); +void setupEncryptOwnerPassword(); +void beginEncrypt40bit(JSON); +void endEncrypt40bit(); +void beginEncrypt128bit(JSON); +void endEncrypt128bit(); +void beginEncrypt256bit(JSON); +void endEncrypt256bit(); +void beginJsonKeyArray(JSON); +void endJsonKeyArray(); +void beginJsonObjectArray(JSON); +void endJsonObjectArray(); +void beginAddAttachmentArray(JSON); +void endAddAttachmentArray(); +void beginAddAttachment(JSON); +void endAddAttachment(); +void setupAddAttachmentFile(); +void beginCopyAttachmentsFromArray(JSON); +void endCopyAttachmentsFromArray(); +void beginCopyAttachmentsFrom(JSON); +void endCopyAttachmentsFrom(); +void setupCopyAttachmentsFromFile(); +void setupCopyAttachmentsFromPassword(); +void beginPagesArray(JSON); +void endPagesArray(); +void beginPages(JSON); +void endPages(); +void setupPagesFile(); +void setupPagesPassword(); +void setupPagesRange(); +void beginOverlay(JSON); +void endOverlay(); +void setupOverlayFile(); +void setupOverlayPassword(); +void beginUnderlay(JSON); +void endUnderlay(); +void setupUnderlayFile(); +void setupUnderlayPassword(); diff --git a/libqpdf/qpdf/auto_job_json_init.hh b/libqpdf/qpdf/auto_job_json_init.hh index df55d328..3d19c76e 100644 --- a/libqpdf/qpdf/auto_job_json_init.hh +++ b/libqpdf/qpdf/auto_job_json_init.hh @@ -15,31 +15,24 @@ static char const* json_key_choices[] = {"acroform", "attachments", "encrypt", " static char const* print128_choices[] = {"full", "low", "none", 0}; static char const* modify128_choices[] = {"all", "annotate", "form", "assembly", "none", 0}; -pushKey("input"); -beginDict(bindJSON(&Handlers::beginInput), bindBare(&Handlers::endInput)); // .input -pushKey("file"); +pushKey("inputFile"); setupInputFile(); -popHandler(); // key: file +popHandler(); // key: inputFile pushKey("password"); -setupInputPassword(); +setupPassword(); popHandler(); // key: password pushKey("passwordFile"); addParameter([this](char const* p) { c_main->passwordFile(p); }); popHandler(); // key: passwordFile pushKey("empty"); -setupInputEmpty(); +setupEmpty(); popHandler(); // key: empty -popHandler(); // key: input -pushKey("output"); -beginDict(bindJSON(&Handlers::beginOutput), bindBare(&Handlers::endOutput)); // .output -pushKey("file"); +pushKey("outputFile"); setupOutputFile(); -popHandler(); // key: file +popHandler(); // key: outputFile pushKey("replaceInput"); -setupOutputReplaceInput(); +setupReplaceInput(); popHandler(); // key: replaceInput -pushKey("options"); -beginDict(bindJSON(&Handlers::beginOutputOptions), bindBare(&Handlers::endOutputOptions)); // .output.options pushKey("qdf"); addBare([this]() { c_main->qdf(); }); popHandler(); // key: qdf @@ -107,15 +100,15 @@ pushKey("splitPages"); addParameter([this](char const* p) { c_main->splitPages(p); }); popHandler(); // key: splitPages pushKey("encrypt"); -beginDict(bindJSON(&Handlers::beginOutputOptionsEncrypt), bindBare(&Handlers::endOutputOptionsEncrypt)); // .output.options.encrypt +beginDict(bindJSON(&Handlers::beginEncrypt), bindBare(&Handlers::endEncrypt)); // .encrypt pushKey("userPassword"); -setupOutputOptionsEncryptUserPassword(); +setupEncryptUserPassword(); popHandler(); // key: userPassword pushKey("ownerPassword"); -setupOutputOptionsEncryptOwnerPassword(); +setupEncryptOwnerPassword(); popHandler(); // key: ownerPassword pushKey("40bit"); -beginDict(bindJSON(&Handlers::beginOutputOptionsEncrypt40bit), bindBare(&Handlers::endOutputOptionsEncrypt40bit)); // .output.options.encrypt.40bit +beginDict(bindJSON(&Handlers::beginEncrypt40bit), bindBare(&Handlers::endEncrypt40bit)); // .encrypt.40bit pushKey("annotate"); addChoices(yn_choices, [this](char const* p) { c_enc->annotate(p); }); popHandler(); // key: annotate @@ -130,7 +123,7 @@ addChoices(print128_choices, [this](char const* p) { c_enc->print(p); }); popHandler(); // key: print popHandler(); // key: 40bit pushKey("128bit"); -beginDict(bindJSON(&Handlers::beginOutputOptionsEncrypt128bit), bindBare(&Handlers::endOutputOptionsEncrypt128bit)); // .output.options.encrypt.128bit +beginDict(bindJSON(&Handlers::beginEncrypt128bit), bindBare(&Handlers::endEncrypt128bit)); // .encrypt.128bit pushKey("accessibility"); addChoices(yn_choices, [this](char const* p) { c_enc->accessibility(p); }); popHandler(); // key: accessibility @@ -166,7 +159,7 @@ addChoices(yn_choices, [this](char const* p) { c_enc->useAes(p); }); popHandler(); // key: useAes popHandler(); // key: 128bit pushKey("256bit"); -beginDict(bindJSON(&Handlers::beginOutputOptionsEncrypt256bit), bindBare(&Handlers::endOutputOptionsEncrypt256bit)); // .output.options.encrypt.256bit +beginDict(bindJSON(&Handlers::beginEncrypt256bit), bindBare(&Handlers::endEncrypt256bit)); // .encrypt.256bit pushKey("accessibility"); addChoices(yn_choices, [this](char const* p) { c_enc->accessibility(p); }); popHandler(); // key: accessibility @@ -202,10 +195,6 @@ addBare([this]() { c_enc->forceR5(); }); popHandler(); // key: forceR5 popHandler(); // key: 256bit popHandler(); // key: encrypt -popHandler(); // key: options -popHandler(); // key: output -pushKey("inspect"); -beginDict(bindJSON(&Handlers::beginInspect), bindBare(&Handlers::endInspect)); // .inspect pushKey("check"); addBare([this]() { c_main->check(); }); popHandler(); // key: check @@ -252,18 +241,15 @@ pushKey("json"); addChoices(json_version_choices, [this](char const* p) { c_main->json(p); }); popHandler(); // key: json pushKey("jsonKey"); -beginArray(bindJSON(&Handlers::beginInspectJsonKeyArray), bindBare(&Handlers::endInspectJsonKeyArray)); // .inspect.jsonKey[] +beginArray(bindJSON(&Handlers::beginJsonKeyArray), bindBare(&Handlers::endJsonKeyArray)); // .jsonKey[] addChoices(json_key_choices, [this](char const* p) { c_main->jsonKey(p); }); -popHandler(); // array: .inspect.jsonKey[] +popHandler(); // array: .jsonKey[] popHandler(); // key: jsonKey pushKey("jsonObject"); -beginArray(bindJSON(&Handlers::beginInspectJsonObjectArray), bindBare(&Handlers::endInspectJsonObjectArray)); // .inspect.jsonObject[] +beginArray(bindJSON(&Handlers::beginJsonObjectArray), bindBare(&Handlers::endJsonObjectArray)); // .jsonObject[] addParameter([this](char const* p) { c_main->jsonObject(p); }); -popHandler(); // array: .inspect.jsonObject[] +popHandler(); // array: .jsonObject[] popHandler(); // key: jsonObject -popHandler(); // key: inspect -pushKey("options"); -beginDict(bindJSON(&Handlers::beginOptions), bindBare(&Handlers::endOptions)); // .options pushKey("allowWeakCrypto"); addBare([this]() { c_main->allowWeakCrypto(); }); popHandler(); // key: allowWeakCrypto @@ -310,10 +296,10 @@ pushKey("removeUnreferencedResources"); addChoices(remove_unref_choices, [this](char const* p) { c_main->removeUnreferencedResources(p); }); popHandler(); // key: removeUnreferencedResources pushKey("addAttachment"); -beginArray(bindJSON(&Handlers::beginOptionsAddAttachmentArray), bindBare(&Handlers::endOptionsAddAttachmentArray)); // .options.addAttachment[] -beginDict(bindJSON(&Handlers::beginOptionsAddAttachment), bindBare(&Handlers::endOptionsAddAttachment)); // .options.addAttachment +beginArray(bindJSON(&Handlers::beginAddAttachmentArray), bindBare(&Handlers::endAddAttachmentArray)); // .addAttachment[] +beginDict(bindJSON(&Handlers::beginAddAttachment), bindBare(&Handlers::endAddAttachment)); // .addAttachment pushKey("file"); -setupOptionsAddAttachmentFile(); +setupAddAttachmentFile(); popHandler(); // key: file pushKey("creationdate"); addParameter([this](char const* p) { c_att->creationdate(p); }); @@ -336,24 +322,24 @@ popHandler(); // key: moddate pushKey("replace"); addBare([this]() { c_att->replace(); }); popHandler(); // key: replace -popHandler(); // array: .options.addAttachment[] +popHandler(); // array: .addAttachment[] popHandler(); // key: addAttachment pushKey("removeAttachment"); addParameter([this](char const* p) { c_main->removeAttachment(p); }); popHandler(); // key: removeAttachment pushKey("copyAttachmentsFrom"); -beginArray(bindJSON(&Handlers::beginOptionsCopyAttachmentsFromArray), bindBare(&Handlers::endOptionsCopyAttachmentsFromArray)); // .options.copyAttachmentsFrom[] -beginDict(bindJSON(&Handlers::beginOptionsCopyAttachmentsFrom), bindBare(&Handlers::endOptionsCopyAttachmentsFrom)); // .options.copyAttachmentsFrom +beginArray(bindJSON(&Handlers::beginCopyAttachmentsFromArray), bindBare(&Handlers::endCopyAttachmentsFromArray)); // .copyAttachmentsFrom[] +beginDict(bindJSON(&Handlers::beginCopyAttachmentsFrom), bindBare(&Handlers::endCopyAttachmentsFrom)); // .copyAttachmentsFrom pushKey("file"); -setupOptionsCopyAttachmentsFromFile(); +setupCopyAttachmentsFromFile(); popHandler(); // key: file pushKey("password"); -setupOptionsCopyAttachmentsFromPassword(); +setupCopyAttachmentsFromPassword(); popHandler(); // key: password pushKey("prefix"); addParameter([this](char const* p) { c_copy_att->prefix(p); }); popHandler(); // key: prefix -popHandler(); // array: .options.copyAttachmentsFrom[] +popHandler(); // array: .copyAttachmentsFrom[] popHandler(); // key: copyAttachmentsFrom pushKey("collate"); addParameter([this](char const* p) { c_main->collate(p); }); @@ -383,18 +369,18 @@ pushKey("optimizeImages"); addBare([this]() { c_main->optimizeImages(); }); popHandler(); // key: optimizeImages pushKey("pages"); -beginArray(bindJSON(&Handlers::beginOptionsPagesArray), bindBare(&Handlers::endOptionsPagesArray)); // .options.pages[] -beginDict(bindJSON(&Handlers::beginOptionsPages), bindBare(&Handlers::endOptionsPages)); // .options.pages +beginArray(bindJSON(&Handlers::beginPagesArray), bindBare(&Handlers::endPagesArray)); // .pages[] +beginDict(bindJSON(&Handlers::beginPages), bindBare(&Handlers::endPages)); // .pages pushKey("file"); -setupOptionsPagesFile(); +setupPagesFile(); popHandler(); // key: file pushKey("password"); -setupOptionsPagesPassword(); +setupPagesPassword(); popHandler(); // key: password pushKey("range"); -setupOptionsPagesRange(); +setupPagesRange(); popHandler(); // key: range -popHandler(); // array: .options.pages[] +popHandler(); // array: .pages[] popHandler(); // key: pages pushKey("removePageLabels"); addBare([this]() { c_main->removePageLabels(); }); @@ -403,12 +389,12 @@ pushKey("rotate"); addParameter([this](char const* p) { c_main->rotate(p); }); popHandler(); // key: rotate pushKey("overlay"); -beginDict(bindJSON(&Handlers::beginOptionsOverlay), bindBare(&Handlers::endOptionsOverlay)); // .options.overlay +beginDict(bindJSON(&Handlers::beginOverlay), bindBare(&Handlers::endOverlay)); // .overlay pushKey("file"); -setupOptionsOverlayFile(); +setupOverlayFile(); popHandler(); // key: file pushKey("password"); -setupOptionsOverlayPassword(); +setupOverlayPassword(); popHandler(); // key: password pushKey("from"); addParameter([this](char const* p) { c_uo->from(p); }); @@ -421,12 +407,12 @@ addParameter([this](char const* p) { c_uo->to(p); }); popHandler(); // key: to popHandler(); // key: overlay pushKey("underlay"); -beginDict(bindJSON(&Handlers::beginOptionsUnderlay), bindBare(&Handlers::endOptionsUnderlay)); // .options.underlay +beginDict(bindJSON(&Handlers::beginUnderlay), bindBare(&Handlers::endUnderlay)); // .underlay pushKey("file"); -setupOptionsUnderlayFile(); +setupUnderlayFile(); popHandler(); // key: file pushKey("password"); -setupOptionsUnderlayPassword(); +setupUnderlayPassword(); popHandler(); // key: password pushKey("from"); addParameter([this](char const* p) { c_uo->from(p); }); @@ -438,4 +424,18 @@ pushKey("to"); addParameter([this](char const* p) { c_uo->to(p); }); popHandler(); // key: to popHandler(); // key: underlay -popHandler(); // key: options +pushKey("warningExit0"); +addBare([this]() { c_main->warningExit0(); }); +popHandler(); // key: warningExit0 +pushKey("jobJsonFile"); +addParameter([this](char const* p) { c_main->jobJsonFile(p); }); +popHandler(); // key: jobJsonFile +pushKey("preserveUnreferencedResources"); +addBare([this]() { c_main->preserveUnreferencedResources(); }); +popHandler(); // key: preserveUnreferencedResources +pushKey("requiresPassword"); +addBare([this]() { c_main->requiresPassword(); }); +popHandler(); // key: requiresPassword +pushKey("isEncrypted"); +addBare([this]() { c_main->isEncrypted(); }); +popHandler(); // key: isEncrypted diff --git a/libqpdf/qpdf/auto_job_schema.hh b/libqpdf/qpdf/auto_job_schema.hh index df430a27..e5bbb866 100644 --- a/libqpdf/qpdf/auto_job_schema.hh +++ b/libqpdf/qpdf/auto_job_schema.hh @@ -1,164 +1,159 @@ static constexpr char const* JOB_SCHEMA_DATA = R"({ - "input": { - "file": "input filename", - "password": "specify password", - "passwordFile": "read password from a file", - "empty": "empty input file" - }, - "output": { - "file": "output filename", - "replaceInput": "set to true to replace input", - "options": { - "qdf": "enable viewing PDF code in a text editor", - "preserveUnreferenced": "preserve unreferenced objects", - "newlineBeforeEndstream": "force a newline before endstream", - "normalizeContent": "fix newlines in content streams", - "streamData": "control stream compression", - "compressStreams": "compress uncompressed streams", - "recompressFlate": "uncompress and recompress flate", - "decodeLevel": "control which streams to uncompress", - "decrypt": "remove encryption from input file", - "deterministicId": "generate ID deterministically", - "staticAesIv": "use a fixed AES vector", - "staticId": "use a fixed document ID", - "noOriginalObjectIds": "omit original object IDs in qdf", - "copyEncryption": "copy another file's encryption details", - "encryptionFilePassword": "supply password for copyEncryption", - "linearize": "linearize (web-optimize) output", - "linearizePass1": "save pass 1 of linearization", - "objectStreams": "control use of object streams", - "minVersion": "set minimum PDF version", - "forceVersion": "set output PDF version", - "progress": "show progress when writing", - "splitPages": "write pages to separate files", - "encrypt": { - "userPassword": "user password", - "ownerPassword": "owner password", - "40bit": { - "annotate": "restrict document annotation", - "extract": "restrict text/graphic extraction", - "modify": "restrict document modification", - "print": "restrict printing" - }, - "128bit": { - "accessibility": "restrict document accessibility", - "annotate": "restrict document annotation", - "assemble": "restrict document assembly", - "cleartextMetadata": "don't encrypt metadata", - "extract": "restrict text/graphic extraction", - "form": "restrict form filling", - "modifyOther": "restrict other modifications", - "modify": "restrict document modification", - "print": "restrict printing", - "forceV4": "force V=4 in encryption dictionary", - "useAes": "use AES with 128-bit encryption" - }, - "256bit": { - "accessibility": "restrict document accessibility", - "annotate": "restrict document annotation", - "assemble": "restrict document assembly", - "cleartextMetadata": "don't encrypt metadata", - "extract": "restrict text/graphic extraction", - "form": "restrict form filling", - "modifyOther": "restrict other modifications", - "modify": "restrict document modification", - "print": "restrict printing", - "allowInsecure": "allow empty owner passwords", - "forceR5": "use unsupported R=5 encryption" - } - } + "inputFile": "input filename", + "password": "specify password", + "passwordFile": "read password from a file", + "empty": "empty input file", + "outputFile": "output filename", + "replaceInput": "replace input with output", + "qdf": "enable viewing PDF code in a text editor", + "preserveUnreferenced": "preserve unreferenced objects", + "newlineBeforeEndstream": "force a newline before endstream", + "normalizeContent": "fix newlines in content streams", + "streamData": "control stream compression", + "compressStreams": "compress uncompressed streams", + "recompressFlate": "uncompress and recompress flate", + "decodeLevel": "control which streams to uncompress", + "decrypt": "remove encryption from input file", + "deterministicId": "generate ID deterministically", + "staticAesIv": "use a fixed AES vector", + "staticId": "use a fixed document ID", + "noOriginalObjectIds": "omit original object IDs in qdf", + "copyEncryption": "copy another file's encryption details", + "encryptionFilePassword": "supply password for copyEncryption", + "linearize": "linearize (web-optimize) output", + "linearizePass1": "save pass 1 of linearization", + "objectStreams": "control use of object streams", + "minVersion": "set minimum PDF version", + "forceVersion": "set output PDF version", + "progress": "show progress when writing", + "splitPages": "write pages to separate files", + "encrypt": { + "userPassword": "user password", + "ownerPassword": "owner password", + "40bit": { + "annotate": "restrict document annotation", + "extract": "restrict text/graphic extraction", + "modify": "restrict document modification", + "print": "restrict printing" + }, + "128bit": { + "accessibility": "restrict document accessibility", + "annotate": "restrict document annotation", + "assemble": "restrict document assembly", + "cleartextMetadata": "don't encrypt metadata", + "extract": "restrict text/graphic extraction", + "form": "restrict form filling", + "modifyOther": "restrict other modifications", + "modify": "restrict document modification", + "print": "restrict printing", + "forceV4": "force V=4 in encryption dictionary", + "useAes": "use AES with 128-bit encryption" + }, + "256bit": { + "accessibility": "restrict document accessibility", + "annotate": "restrict document annotation", + "assemble": "restrict document assembly", + "cleartextMetadata": "don't encrypt metadata", + "extract": "restrict text/graphic extraction", + "form": "restrict form filling", + "modifyOther": "restrict other modifications", + "modify": "restrict document modification", + "print": "restrict printing", + "allowInsecure": "allow empty owner passwords", + "forceR5": "use unsupported R=5 encryption" } }, - "inspect": { - "check": "partially check whether PDF is valid", - "checkLinearization": "check linearization tables", - "filteredStreamData": "show filtered stream data", - "rawStreamData": "show raw stream data", - "showEncryption": "information about encrypted files", - "showEncryptionKey": "show key with showEncryption", - "showLinearization": "show linearization hint tables", - "showNpages": "show number of pages", - "showObject": "show contents of an object", - "showPages": "display page dictionary information", - "showXref": "show cross reference data", - "withImages": "include image details with showPages", - "listAttachments": "list embedded files", - "showAttachment": "export an embedded file", - "json": "show file in json format", - "jsonKey": [ - "restrict which keys are in json output" - ], - "jsonObject": [ - "restrict which objects are in JSON" - ] - }, - "options": { - "allowWeakCrypto": "allow insecure cryptographic algorithms", - "keepFilesOpen": "manage keeping multiple files open", - "keepFilesOpenThreshold": "set threshold for keepFilesOpen", - "noWarn": "suppress printing of warning messages", - "verbose": "print additional information", - "ignoreXrefStreams": "use xref tables rather than streams", - "passwordIsHexKey": "provide hex-encoded encryption key", - "passwordMode": "tweak how qpdf encodes passwords", - "suppressPasswordRecovery": "don't try different password encodings", - "suppressRecovery": "suppress error recovery", - "coalesceContents": "combine content streams", - "compressionLevel": "set compression level for flate", - "externalizeInlineImages": "convert inline to regular images", - "iiMinBytes": "set minimum size for externalizeInlineImages", - "removeUnreferencedResources": "remove unreferenced page resources", - "addAttachment": [ - { - "file": "attachment to add", - "creationdate": "set attachment's creation date", - "description": "set attachment's description", - "filename": "set attachment's displayed filename", - "key": "specify attachment key", - "mimetype": "attachment mime type, e.g. application/pdf", - "moddate": "set attachment's modification date", - "replace": "replace attachment with same key" - } - ], - "removeAttachment": "remove an embedded file", - "copyAttachmentsFrom": [ - { - "file": "attachment source filename", - "password": "specify password", - "prefix": "key prefix for copying attachments" - } - ], - "collate": "collate with pages", - "flattenAnnotations": "push annotations into content", - "flattenRotation": "remove rotation from page dictionary", - "generateAppearances": "generate appearances for form fields", - "keepInlineImages": "exclude inline images from optimization", - "oiMinArea": "minimum area for optimizeImages", - "oiMinHeight": "minimum height for optimizeImages", - "oiMinWidth": "minimum width for optimizeImages", - "optimizeImages": "use efficient compression for images", - "pages": [ - { - "file": "source for for pages", - "password": "specify password", - "range": "page range" - } - ], - "removePageLabels": "remove explicit page numbers", - "rotate": "rotate pages", - "overlay": { - "file": "source file for overlay", + "check": "partially check whether PDF is valid", + "checkLinearization": "check linearization tables", + "filteredStreamData": "show filtered stream data", + "rawStreamData": "show raw stream data", + "showEncryption": "information about encrypted files", + "showEncryptionKey": "show key with showEncryption", + "showLinearization": "show linearization hint tables", + "showNpages": "show number of pages", + "showObject": "show contents of an object", + "showPages": "display page dictionary information", + "showXref": "show cross reference data", + "withImages": "include image details with showPages", + "listAttachments": "list embedded files", + "showAttachment": "export an embedded file", + "json": "show file in json format", + "jsonKey": [ + "restrict which keys are in json output" + ], + "jsonObject": [ + "restrict which objects are in JSON" + ], + "allowWeakCrypto": "allow insecure cryptographic algorithms", + "keepFilesOpen": "manage keeping multiple files open", + "keepFilesOpenThreshold": "set threshold for keepFilesOpen", + "noWarn": "suppress printing of warning messages", + "verbose": "print additional information", + "ignoreXrefStreams": "use xref tables rather than streams", + "passwordIsHexKey": "provide hex-encoded encryption key", + "passwordMode": "tweak how qpdf encodes passwords", + "suppressPasswordRecovery": "don't try different password encodings", + "suppressRecovery": "suppress error recovery", + "coalesceContents": "combine content streams", + "compressionLevel": "set compression level for flate", + "externalizeInlineImages": "convert inline to regular images", + "iiMinBytes": "set minimum size for externalizeInlineImages", + "removeUnreferencedResources": "remove unreferenced page resources", + "addAttachment": [ + { + "file": "attachment to add", + "creationdate": "set attachment's creation date", + "description": "set attachment's description", + "filename": "set attachment's displayed filename", + "key": "specify attachment key", + "mimetype": "attachment mime type, e.g. application/pdf", + "moddate": "set attachment's modification date", + "replace": "replace attachment with same key" + } + ], + "removeAttachment": "remove an embedded file", + "copyAttachmentsFrom": [ + { + "file": "attachment source filename", "password": "specify password", - "from": "source pages for underlay/overlay", - "repeat": "overlay/underlay pages to repeat", - "to": "destination pages for underlay/overlay" - }, - "underlay": { - "file": "source file for underlay", + "prefix": "key prefix for copying attachments" + } + ], + "collate": "collate with pages", + "flattenAnnotations": "push annotations into content", + "flattenRotation": "remove rotation from page dictionary", + "generateAppearances": "generate appearances for form fields", + "keepInlineImages": "exclude inline images from optimization", + "oiMinArea": "minimum area for optimizeImages", + "oiMinHeight": "minimum height for optimizeImages", + "oiMinWidth": "minimum width for optimizeImages", + "optimizeImages": "use efficient compression for images", + "pages": [ + { + "file": "source for for pages", "password": "specify password", - "from": "source pages for underlay/overlay", - "repeat": "overlay/underlay pages to repeat", - "to": "destination pages for underlay/overlay" + "range": "page range" } - } + ], + "removePageLabels": "remove explicit page numbers", + "rotate": "rotate pages", + "overlay": { + "file": "source file for overlay", + "password": "specify password", + "from": "source pages for underlay/overlay", + "repeat": "overlay/underlay pages to repeat", + "to": "destination pages for underlay/overlay" + }, + "underlay": { + "file": "source file for underlay", + "password": "specify password", + "from": "source pages for underlay/overlay", + "repeat": "overlay/underlay pages to repeat", + "to": "destination pages for underlay/overlay" + }, + "warningExit0": "exit 0 even with warnings", + "jobJsonFile": "job JSON file", + "preserveUnreferencedResources": "use removeUnreferencedResourcesNo", + "requiresPassword": "silently test a file's password", + "isEncrypted": "silently test whether a file is encrypted" })"; -- cgit v1.2.3-54-g00ecf