diff --git a/generate_auto_job b/generate_auto_job index 63eb4350..5993a48e 100755 --- a/generate_auto_job +++ b/generate_auto_job @@ -562,7 +562,7 @@ class Main: def generate_schema(self, data): # Check to make sure that every command-line option is - # represented either in data['json'] or data['no-json']. + # represented in data['json']. # Build a list of options that we expect. If an option appears # once, we just expect to see it once. If it appears in more @@ -578,7 +578,7 @@ class Main: else: for t in sorted(tables): expected[f'{t}.{k}'] = {**v} - options_seen = set(data['no-json']) + options_seen = set() # Walk through the json information building the schema as we # go. This verifies consistency between command-line options @@ -600,7 +600,7 @@ class Main: def validate(self, data): self.check_keys('top', data, set( - ['choices', 'options', 'no-json', 'json'])) + ['choices', 'options', 'json'])) for o in data['options']: self.check_keys('top', o, set( ['table', 'prefix', 'config', 'config_prefix', diff --git a/job.sums b/job.sums index 0360a53d..bc5be54c 100644 --- a/job.sums +++ b/job.sums @@ -1,17 +1,17 @@ # Generated by generate_auto_job -generate_auto_job ef1b438aeebed7ca0afcbe4d1f9c54d3acf899aec8410ebc69cd15ec673dd158 +generate_auto_job 905fed38c06d258af617ac909bed78a7888a5eaba3f14cf143168665f6e90a86 include/qpdf/auto_job_c_att.hh 7ad43bb374c1370ef32ebdcdcb7b73a61d281f7f4e3f12755585872ab30fb60e include/qpdf/auto_job_c_copy_att.hh 32275d03cdc69b703dd7e02ba0bbe15756e714e9ad185484773a6178dc09e1ee include/qpdf/auto_job_c_enc.hh 72e138c7b96ed5aacdce78c1dec04b1c20d361faec4f8faf52f64c1d6be99265 include/qpdf/auto_job_c_main.hh ff776dd643279330fbf59770d1abf5aaeb13f20bfc5f6a25997aaa72a0907b44 include/qpdf/auto_job_c_pages.hh 931840b329a36ca0e41401190e04537b47f2867671a6643bfd8da74014202671 include/qpdf/auto_job_c_uo.hh 0585b7de459fa479d9e51a45fa92de0ff6dee748efc9ec1cedd0dde6cee1ad50 -job.yml c3e714b3c3e2fc85390d983302ff398aa0992c621e85dbcaee20173b1bd3cb0b +job.yml 92565dc8023ea880aca5b96c2620f756642a6dafa5ed15546bc2c777c31b218e libqpdf/qpdf/auto_job_decl.hh 9f79396ec459f191be4c5fe34cf88c265cf47355a1a945fa39169d1c94cf04f6 libqpdf/qpdf/auto_job_help.hh a0ab6ab4dde2ad3d3f17ecae3ea274919119329e075061f3a3973535f5e367de libqpdf/qpdf/auto_job_init.hh c244e03e8b83ed7db732920f40aff0134e5f2e78a6edb9473ea4dd1934a8953e -libqpdf/qpdf/auto_job_json_decl.hh 741a44106f7850b6cbc8af264b5b77bb605475c8d8dd8cd87011d5debbee6269 -libqpdf/qpdf/auto_job_json_init.hh 63bbe1c3d673cd56196ec42ec7ede7b531563667d83564aa6680634fcb2cf259 -libqpdf/qpdf/auto_job_schema.hh a764050cc99f1cc95645fd1ea2f020c4b778957abc64fbc55c12eac3a369dc92 +libqpdf/qpdf/auto_job_json_decl.hh c5e3fd38a3b0c569eb0c6b4c60953a09cd6bc7d3361a357a81f64fe36af2b0cf +libqpdf/qpdf/auto_job_json_init.hh bfaf88ad1461e1157e7a0eb6e8c90669eba6d03b5b1ffd2e7e7041250c5f0523 +libqpdf/qpdf/auto_job_schema.hh 2ec70dffdd15974d74102b4d7ada9f97449bc28c98be119efee5e15507ed22a8 manual/_ext/qpdf.py e9ac9d6c70642a3d29281ee5ad92ae2422dee8be9306fb8a0bc9dba0ed5e28f3 manual/cli.rst a75a7e34aa9aba4f06e9c88cae9a2d9a2aa4e55a08521dde1478e8f2d80aadab diff --git a/job.yml b/job.yml index 4b1df7cf..4f072ebd 100644 --- a/job.yml +++ b/job.yml @@ -243,13 +243,6 @@ options: required_parameter: prefix: prefix password: password -no-json: - - preserve-unreferenced-resources - - job-json-file - - replace-input - - warning-exit-0 - - requires-password - - is-encrypted json: # The structure of this section defines what the json input to # QPDFJob looks like. If a key starts with underscore, it does not @@ -262,143 +255,149 @@ json: # 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: - _file: "input filename" - main.password: - password-file: - empty: - _output: - _file: "output filename" - _replace-input: "set to true to replace input" - _options: - qdf: - preserve-unreferenced: - newline-before-endstream: - normalize-content: - stream-data: - compress-streams: - recompress-flate: - decode-level: - decrypt: - deterministic-id: - static-aes-iv: - static-id: - no-original-object-ids: - copy-encryption: - encryption-file-password: - linearize: - linearize-pass1: - object-streams: - min-version: - force-version: - progress: - split-pages: - encrypt: - _user-password: "user password" - _owner-password: "owner password" - _40bit: - Enc40.annotate: - Enc40.extract: - Enc40.modify: - Enc40.print: - _128bit: - Enc128.accessibility: - Enc128.annotate: - Enc128.assemble: - Enc128.cleartext-metadata: - Enc128.extract: - Enc128.form: - Enc128.modify-other: - Enc128.modify: - Enc128.print: - force-V4: - use-aes: - _256bit: - Enc256.accessibility: - Enc256.annotate: - Enc256.assemble: - Enc256.cleartext-metadata: - Enc256.extract: - Enc256.form: - Enc256.modify-other: - Enc256.modify: - Enc256.print: - allow-insecure: - force-R5: - _inspect: - check: - check-linearization: - filtered-stream-data: - raw-stream-data: - show-encryption: - show-encryption-key: - show-linearization: - show-npages: - show-object: - show-pages: - show-xref: - with-images: - list-attachments: - show-attachment: - json: - json-key: - - null - json-object: - - null - _options: - allow-weak-crypto: - keep-files-open: - keep-files-open-threshold: - no-warn: - verbose: - ignore-xref-streams: - password-is-hex-key: - password-mode: - suppress-password-recovery: - suppress-recovery: - coalesce-contents: - compression-level: - externalize-inline-images: - ii-min-bytes: - remove-unreferenced-resources: - add-attachment: - - _file: "attachment to add" - creationdate: - description: - filename: - key: - mimetype: - moddate: - replace: - remove-attachment: - copy-attachments-from: - - _file: "attachment source filename" - CopyAtt.password: - prefix: - collate: - flatten-annotations: - flatten-rotation: - generate-appearances: - keep-inline-images: - oi-min-area: - oi-min-height: - oi-min-width: - optimize-images: - pages: - - _file: "source for for pages" - Pages.password: - _range: "page range" - remove-page-labels: - rotate: - overlay: - _file: "source file for overlay" - UO.password: - from: - repeat: - to: - underlay: - _file: "source file for underlay" - UO.password: - from: - repeat: - to: + + # input + _inputFile: "input filename" + main.password: + password-file: + empty: + # output + _outputFile: "output filename" + replace-input: + # output options + qdf: + preserve-unreferenced: + newline-before-endstream: + normalize-content: + stream-data: + compress-streams: + recompress-flate: + decode-level: + decrypt: + deterministic-id: + static-aes-iv: + static-id: + no-original-object-ids: + copy-encryption: + encryption-file-password: + linearize: + linearize-pass1: + object-streams: + min-version: + force-version: + progress: + split-pages: + encrypt: + _user-password: "user password" + _owner-password: "owner password" + _40bit: + Enc40.annotate: + Enc40.extract: + Enc40.modify: + Enc40.print: + _128bit: + Enc128.accessibility: + Enc128.annotate: + Enc128.assemble: + Enc128.cleartext-metadata: + Enc128.extract: + Enc128.form: + Enc128.modify-other: + Enc128.modify: + Enc128.print: + force-V4: + use-aes: + _256bit: + Enc256.accessibility: + Enc256.annotate: + Enc256.assemble: + Enc256.cleartext-metadata: + Enc256.extract: + Enc256.form: + Enc256.modify-other: + Enc256.modify: + Enc256.print: + allow-insecure: + force-R5: + # inspect + check: + check-linearization: + filtered-stream-data: + raw-stream-data: + show-encryption: + show-encryption-key: + show-linearization: + show-npages: + show-object: + show-pages: + show-xref: + with-images: + list-attachments: + show-attachment: + json: + json-key: + - null + json-object: + - null + # other options + allow-weak-crypto: + keep-files-open: + keep-files-open-threshold: + no-warn: + verbose: + ignore-xref-streams: + password-is-hex-key: + password-mode: + suppress-password-recovery: + suppress-recovery: + coalesce-contents: + compression-level: + externalize-inline-images: + ii-min-bytes: + remove-unreferenced-resources: + add-attachment: + - _file: "attachment to add" + creationdate: + description: + filename: + key: + mimetype: + moddate: + replace: + remove-attachment: + copy-attachments-from: + - _file: "attachment source filename" + CopyAtt.password: + prefix: + collate: + flatten-annotations: + flatten-rotation: + generate-appearances: + keep-inline-images: + oi-min-area: + oi-min-height: + oi-min-width: + optimize-images: + pages: + - _file: "source for for pages" + Pages.password: + _range: "page range" + remove-page-labels: + rotate: + overlay: + _file: "source file for overlay" + UO.password: + from: + repeat: + to: + underlay: + _file: "source file for underlay" + UO.password: + from: + repeat: + to: + warning-exit-0: + job-json-file: + preserve-unreferenced-resources: + requires-password: + is-encrypted: 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) +Handlers::beginEncrypt40bit(JSON) { // nothing needed } void -Handlers::endOutputOptionsEncrypt40bit() +Handlers::endEncrypt40bit() { // nothing needed } void -Handlers::beginOutputOptionsEncrypt128bit(JSON) +Handlers::beginEncrypt128bit(JSON) { // nothing needed } void -Handlers::endOutputOptionsEncrypt128bit() +Handlers::endEncrypt128bit() { // nothing needed } void -Handlers::beginOutputOptionsEncrypt256bit(JSON) +Handlers::beginEncrypt256bit(JSON) { // nothing needed } void -Handlers::endOutputOptionsEncrypt256bit() +Handlers::endEncrypt256bit() { // nothing needed } void -Handlers::beginOptions(JSON) +Handlers::beginJsonKeyArray(JSON) { // nothing needed } void -Handlers::endOptions() +Handlers::endJsonKeyArray() { // nothing needed } void -Handlers::beginInspect(JSON) +Handlers::beginJsonObjectArray(JSON) { // nothing needed } void -Handlers::endInspect() +Handlers::endJsonObjectArray() { // nothing needed } void -Handlers::beginInspectJsonKeyArray(JSON) +Handlers::beginAddAttachmentArray(JSON) { // nothing needed } void -Handlers::endInspectJsonKeyArray() +Handlers::endAddAttachmentArray() { // nothing needed } void -Handlers::beginInspectJsonObjectArray(JSON) -{ - // nothing needed -} - -void -Handlers::endInspectJsonObjectArray() -{ - // nothing needed -} - -void -Handlers::beginOptionsAddAttachmentArray(JSON) -{ - // nothing needed -} - -void -Handlers::endOptionsAddAttachmentArray() -{ - // 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" - } - } - } - }, - "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", - "password": "specify password", - "from": "source pages for underlay/overlay", - "repeat": "overlay/underlay pages to repeat", - "to": "destination pages for underlay/overlay" + "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" }, - "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" + "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" } - } + }, + "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", + "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", + "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" })"; diff --git a/qpdf/qtest/qpdf/bad-bare-option-false-json.out b/qpdf/qtest/qpdf/bad-bare-option-false-json.out index 6fa389f7..d6086349 100644 --- a/qpdf/qtest/qpdf/bad-bare-option-false-json.out +++ b/qpdf/qtest/qpdf/bad-bare-option-false-json.out @@ -1,5 +1,5 @@ -qpdf: error with job-json file bad-json-bare-option-false.json: .output.options.qdf: value must be true +qpdf: error with job-json file bad-json-bare-option-false.json: .qdf: value must be true Run qpdf--job-json-help for information on the file format. For help: diff --git a/qpdf/qtest/qpdf/bad-choice-mismatch-json.out b/qpdf/qtest/qpdf/bad-choice-mismatch-json.out index 16f7aac9..4f2193a0 100644 --- a/qpdf/qtest/qpdf/bad-choice-mismatch-json.out +++ b/qpdf/qtest/qpdf/bad-choice-mismatch-json.out @@ -1,5 +1,5 @@ -qpdf: error with job-json file bad-json-choice-mismatch.json: .output.options.objectStreams: unexpected value; expected one of disable, preserve, generate +qpdf: error with job-json file bad-json-choice-mismatch.json: .objectStreams: unexpected value; expected one of disable, preserve, generate Run qpdf--job-json-help for information on the file format. For help: diff --git a/qpdf/qtest/qpdf/bad-json-bare-option-false.json b/qpdf/qtest/qpdf/bad-json-bare-option-false.json index c42380a9..721b3914 100644 --- a/qpdf/qtest/qpdf/bad-json-bare-option-false.json +++ b/qpdf/qtest/qpdf/bad-json-bare-option-false.json @@ -1,7 +1,3 @@ { - "output": { - "options": { - "qdf": false - } - } + "qdf": false } diff --git a/qpdf/qtest/qpdf/bad-json-choice-mismatch.json b/qpdf/qtest/qpdf/bad-json-choice-mismatch.json index 45143a14..560bb02e 100644 --- a/qpdf/qtest/qpdf/bad-json-choice-mismatch.json +++ b/qpdf/qtest/qpdf/bad-json-choice-mismatch.json @@ -1,7 +1,3 @@ { - "output": { - "options": { - "objectStreams": "potato" - } - } + "objectStreams": "potato" } diff --git a/qpdf/qtest/qpdf/bad-json-encrypt-duplicate-key-length.json b/qpdf/qtest/qpdf/bad-json-encrypt-duplicate-key-length.json index 4afa96fd..767b6570 100644 --- a/qpdf/qtest/qpdf/bad-json-encrypt-duplicate-key-length.json +++ b/qpdf/qtest/qpdf/bad-json-encrypt-duplicate-key-length.json @@ -1,14 +1,10 @@ { - "output": { - "options": { - "encrypt": { - "userPassword": "", - "ownerPassword": "someOwnerThing", - "256bit": { - }, - "128bit": { - } - } + "encrypt": { + "userPassword": "", + "ownerPassword": "someOwnerThing", + "256bit": { + }, + "128bit": { } } } diff --git a/qpdf/qtest/qpdf/bad-json-encrypt-missing-password.json b/qpdf/qtest/qpdf/bad-json-encrypt-missing-password.json index 8c9a14a5..c4786e22 100644 --- a/qpdf/qtest/qpdf/bad-json-encrypt-missing-password.json +++ b/qpdf/qtest/qpdf/bad-json-encrypt-missing-password.json @@ -1,11 +1,7 @@ { - "output": { - "options": { - "encrypt": { - "userPassword": "", - "256bit": { - } - } + "encrypt": { + "userPassword": "", + "256bit": { } } } diff --git a/qpdf/qtest/qpdf/bad-json-encrypt-no-key-length.json b/qpdf/qtest/qpdf/bad-json-encrypt-no-key-length.json index 997dfe79..37280c3f 100644 --- a/qpdf/qtest/qpdf/bad-json-encrypt-no-key-length.json +++ b/qpdf/qtest/qpdf/bad-json-encrypt-no-key-length.json @@ -1,10 +1,6 @@ { - "output": { - "options": { - "encrypt": { - "userPassword": "", - "ownerPassword": "someOwnerThing" - } - } + "encrypt": { + "userPassword": "", + "ownerPassword": "someOwnerThing" } } diff --git a/qpdf/qtest/qpdf/bad-json-error-json.out b/qpdf/qtest/qpdf/bad-json-error-json.out index e8933d72..6dbf5868 100644 --- a/qpdf/qtest/qpdf/bad-json-error-json.out +++ b/qpdf/qtest/qpdf/bad-json-error-json.out @@ -1,5 +1,5 @@ -qpdf: error with job-json file bad-json-json-error.json: JSON: offset 130: unexpected dictionary end delimiter +qpdf: error with job-json file bad-json-json-error.json: JSON: offset 83: unexpected dictionary end delimiter Run qpdf--job-json-help for information on the file format. For help: diff --git a/qpdf/qtest/qpdf/bad-json-json-error.json b/qpdf/qtest/qpdf/bad-json-json-error.json index 439434a8..cb13df48 100644 --- a/qpdf/qtest/qpdf/bad-json-json-error.json +++ b/qpdf/qtest/qpdf/bad-json-json-error.json @@ -1,10 +1,6 @@ { - "output": { - "options": { - "encrypt": { - "userPassword": "", - "ownerPassword": "someOwnerThing", - } - } + "encrypt": { + "userPassword": "", + "ownerPassword": "someOwnerThing", } } diff --git a/qpdf/qtest/qpdf/bad-json-pages-no-file.json b/qpdf/qtest/qpdf/bad-json-pages-no-file.json index 5d855a32..e5469e9b 100644 --- a/qpdf/qtest/qpdf/bad-json-pages-no-file.json +++ b/qpdf/qtest/qpdf/bad-json-pages-no-file.json @@ -1,9 +1,7 @@ { - "options": { - "pages": [ - { - "range": "1-z" - } - ] - } + "pages": [ + { + "range": "1-z" + } + ] } diff --git a/qpdf/qtest/qpdf/bad-json-schema-error.json b/qpdf/qtest/qpdf/bad-json-schema-error.json index d4d289ac..b211e858 100644 --- a/qpdf/qtest/qpdf/bad-json-schema-error.json +++ b/qpdf/qtest/qpdf/bad-json-schema-error.json @@ -1,12 +1,10 @@ { - "output": { - "potato": { - "encrypt": { - "userPassword": "", - "ownerPassword": "someOwnerThing", - "256bit": { - } - } + "potato": { + }, + "encrypt": { + "userPassword": "", + "ownerPassword": "someOwnerThing", + "256bit": { } } } diff --git a/qpdf/qtest/qpdf/bad-schema-error-json.out b/qpdf/qtest/qpdf/bad-schema-error-json.out index 700a4099..76937a0f 100644 --- a/qpdf/qtest/qpdf/bad-schema-error-json.out +++ b/qpdf/qtest/qpdf/bad-schema-error-json.out @@ -1,6 +1,6 @@ qpdf: error with job-json file bad-json-schema-error.json: qpdf: job json has errors: - json key ".output": key "potato" is not present in schema but appears in object + top-level object: key "potato" is not present in schema but appears in object Run qpdf--job-json-help for information on the file format. For help: diff --git a/qpdf/qtest/qpdf/job-json-add-attachments.json b/qpdf/qtest/qpdf/job-json-add-attachments.json index 9eb03ca4..8a614ab0 100644 --- a/qpdf/qtest/qpdf/job-json-add-attachments.json +++ b/qpdf/qtest/qpdf/job-json-add-attachments.json @@ -1,27 +1,19 @@ { - "input": { - "file": "minimal.pdf" - }, - "output": { - "file": "a.pdf", - "options": { - "staticId": true + "inputFile": "minimal.pdf", + "outputFile": "a.pdf", + "staticId": true, + "addAttachment": [ + { + "file": "auto-txt", + "moddate": "D:20220131134246-05'00'", + "creationdate": "D:20220131134246-05'00'" + }, + { + "file": "auto-txt", + "moddate": "D:20220131134246-05'00'", + "creationdate": "D:20220131134246-05'00'", + "filename": "auto2", + "key": "auto2-key" } - }, - "options": { - "addAttachment": [ - { - "file": "auto-txt", - "moddate": "D:20220131134246-05'00'", - "creationdate": "D:20220131134246-05'00'" - }, - { - "file": "auto-txt", - "moddate": "D:20220131134246-05'00'", - "creationdate": "D:20220131134246-05'00'", - "filename": "auto2", - "key": "auto2-key" - } - ] - } + ] } diff --git a/qpdf/qtest/qpdf/job-json-choice-match.json b/qpdf/qtest/qpdf/job-json-choice-match.json index 555e0f5b..e9f26258 100644 --- a/qpdf/qtest/qpdf/job-json-choice-match.json +++ b/qpdf/qtest/qpdf/job-json-choice-match.json @@ -1,12 +1,6 @@ { - "input": { - "file": "minimal.pdf" - }, - "output": { - "file": "a.pdf", - "options": { - "deterministicId": true, - "objectStreams": "generate" - } - } + "inputFile": "minimal.pdf", + "outputFile": "a.pdf", + "deterministicId": true, + "objectStreams": "generate" } diff --git a/qpdf/qtest/qpdf/job-json-copy-attachments.json b/qpdf/qtest/qpdf/job-json-copy-attachments.json index 7aa531b6..3a5dd83d 100644 --- a/qpdf/qtest/qpdf/job-json-copy-attachments.json +++ b/qpdf/qtest/qpdf/job-json-copy-attachments.json @@ -1,26 +1,18 @@ { - "input": { - "file": "minimal.pdf" - }, - "output": { - "file": "a.pdf", - "options": { - "staticId": true + "inputFile": "minimal.pdf", + "outputFile": "a.pdf", + "staticId": true, + "copyAttachmentsFrom": [ + { + "file": "job-json-add-attachments.pdf" + }, + { + "file": "20-pages.pdf", + "password": "user" + }, + { + "file": "job-json-add-attachments.pdf", + "prefix": "p-" } - }, - "options": { - "copyAttachmentsFrom": [ - { - "file": "job-json-add-attachments.pdf" - }, - { - "file": "20-pages.pdf", - "password": "user" - }, - { - "file": "job-json-add-attachments.pdf", - "prefix": "p-" - } - ] - } + ] } diff --git a/qpdf/qtest/qpdf/job-json-empty-input.json b/qpdf/qtest/qpdf/job-json-empty-input.json index c124169c..952f23ad 100644 --- a/qpdf/qtest/qpdf/job-json-empty-input.json +++ b/qpdf/qtest/qpdf/job-json-empty-input.json @@ -1,23 +1,15 @@ { - "input": { - "empty": true - }, - "output": { - "file": "a.pdf", - "options": { - "staticId": true + "empty": true, + "outputFile": "a.pdf", + "staticId": true, + "pages": [ + { + "file": "minimal.pdf" + }, + { + "file": "20-pages.pdf", + "password": "user", + "range": "1-5" } - }, - "options": { - "pages": [ - { - "file": "minimal.pdf" - }, - { - "file": "20-pages.pdf", - "password": "user", - "range": "1-5" - } - ] - } + ] } diff --git a/qpdf/qtest/qpdf/job-json-encrypt-128.json b/qpdf/qtest/qpdf/job-json-encrypt-128.json index 318dfd6f..35aba91f 100644 --- a/qpdf/qtest/qpdf/job-json-encrypt-128.json +++ b/qpdf/qtest/qpdf/job-json-encrypt-128.json @@ -1,19 +1,13 @@ { - "input": { - "file": "fxo-blue.pdf" - }, - "output": { - "file": "a.pdf", - "options": { - "staticId": true, - "staticAesIv": true, - "encrypt": { - "userPassword": "u", - "ownerPassword": "o", - "128bit": { - "useAes": "y" - } - } + "inputFile": "fxo-blue.pdf", + "outputFile": "a.pdf", + "staticId": true, + "staticAesIv": true, + "encrypt": { + "userPassword": "u", + "ownerPassword": "o", + "128bit": { + "useAes": "y" } } } diff --git a/qpdf/qtest/qpdf/job-json-encrypt-256-with-restrictions.json b/qpdf/qtest/qpdf/job-json-encrypt-256-with-restrictions.json index d9b8d282..55ace1cf 100644 --- a/qpdf/qtest/qpdf/job-json-encrypt-256-with-restrictions.json +++ b/qpdf/qtest/qpdf/job-json-encrypt-256-with-restrictions.json @@ -1,20 +1,14 @@ { - "input": { - "file": "minimal.pdf" - }, - "output": { - "file": "a.pdf", - "options": { - "staticId": true, - "staticAesIv": true, - "encrypt": { - "userPassword": "u", - "ownerPassword": "o", - "256bit": { - "print": "low", - "modify": "form" - } - } + "inputFile": "minimal.pdf", + "outputFile": "a.pdf", + "staticId": true, + "staticAesIv": true, + "encrypt": { + "userPassword": "u", + "ownerPassword": "o", + "256bit": { + "print": "low", + "modify": "form" } } } diff --git a/qpdf/qtest/qpdf/job-json-encrypt-40.json b/qpdf/qtest/qpdf/job-json-encrypt-40.json index 785bbe5d..b5be3b2a 100644 --- a/qpdf/qtest/qpdf/job-json-encrypt-40.json +++ b/qpdf/qtest/qpdf/job-json-encrypt-40.json @@ -1,19 +1,11 @@ { - "input": { - "file": "minimal.pdf" + "inputFile": "minimal.pdf", + "outputFile": "a.pdf", + "staticId": true, + "encrypt": { + "userPassword": "u", + "ownerPassword": "o", + "40bit": {} }, - "output": { - "file": "a.pdf", - "options": { - "staticId": true, - "encrypt": { - "userPassword": "u", - "ownerPassword": "o", - "40bit": {} - } - } - }, - "options": { - "allowWeakCrypto": true - } + "allowWeakCrypto": true } diff --git a/qpdf/qtest/qpdf/job-json-input-file-password.json b/qpdf/qtest/qpdf/job-json-input-file-password.json index 8f22aad0..36ce7833 100644 --- a/qpdf/qtest/qpdf/job-json-input-file-password.json +++ b/qpdf/qtest/qpdf/job-json-input-file-password.json @@ -1,14 +1,8 @@ { - "input": { - "file": "20-pages.pdf", - "password": "user" - }, - "output": { - "file": "a.pdf", - "options": { - "staticId": true, - "staticAesIv": true, - "compressStreams": "n" - } - } + "inputFile": "20-pages.pdf", + "password": "user", + "outputFile": "a.pdf", + "staticId": true, + "staticAesIv": true, + "compressStreams": "n" } diff --git a/qpdf/qtest/qpdf/job-json-misc-options.json b/qpdf/qtest/qpdf/job-json-misc-options.json index 3056f2fe..7b41d3df 100644 --- a/qpdf/qtest/qpdf/job-json-misc-options.json +++ b/qpdf/qtest/qpdf/job-json-misc-options.json @@ -1,13 +1,7 @@ { - "input": { - "file": "minimal.pdf" - }, - "output": { - "file": "a.pdf", - "options": { - "staticId": true, - "linearize": true, - "compressStreams": "n" - } - } + "inputFile": "minimal.pdf", + "outputFile": "a.pdf", + "staticId": true, + "linearize": true, + "compressStreams": "n" } diff --git a/qpdf/qtest/qpdf/job-json-output.json b/qpdf/qtest/qpdf/job-json-output.json index 7110c725..4f5bb612 100644 --- a/qpdf/qtest/qpdf/job-json-output.json +++ b/qpdf/qtest/qpdf/job-json-output.json @@ -1,16 +1,12 @@ { - "input": { - "file": "minimal.pdf" - }, - "inspect": { - "json": "1", - "jsonKey": [ - "pages", - "objects" - ], - "jsonObject": [ - "trailer", - "5" - ] - } + "inputFile": "minimal.pdf", + "json": "1", + "jsonKey": [ + "pages", + "objects" + ], + "jsonObject": [ + "trailer", + "5" + ] } diff --git a/qpdf/qtest/qpdf/job-json-replace-input.json b/qpdf/qtest/qpdf/job-json-replace-input.json index 1e45acfe..3b55755b 100644 --- a/qpdf/qtest/qpdf/job-json-replace-input.json +++ b/qpdf/qtest/qpdf/job-json-replace-input.json @@ -1,12 +1,6 @@ { - "input": { - "file": "a.pdf" - }, - "output": { - "replaceInput": true, - "options": { - "staticId": true, - "objectStreams": "generate" - } - } + "inputFile": "a.pdf", + "replaceInput": true, + "staticId": true, + "objectStreams": "generate" } diff --git a/qpdf/qtest/qpdf/job-json-underlay-overlay-password.json b/qpdf/qtest/qpdf/job-json-underlay-overlay-password.json index 304c1654..643b7df5 100644 --- a/qpdf/qtest/qpdf/job-json-underlay-overlay-password.json +++ b/qpdf/qtest/qpdf/job-json-underlay-overlay-password.json @@ -1,23 +1,15 @@ { - "input": { - "file": "minimal.pdf" + "inputFile": "minimal.pdf", + "outputFile": "a.pdf", + "staticId": true, + "underlay": { + "file": "20-pages.pdf", + "password": "user", + "from": "5" }, - "output": { - "file": "a.pdf", - "options": { - "staticId": true - } - }, - "options": { - "underlay": { - "file": "20-pages.pdf", - "password": "user", - "from": "5" - }, - "overlay": { - "file": "job-json-encrypt-128.pdf", - "password": "o", - "from": "7" - } + "overlay": { + "file": "job-json-encrypt-128.pdf", + "password": "o", + "from": "7" } } diff --git a/qpdf/qtest/qpdf/job-json-underlay-overlay.json b/qpdf/qtest/qpdf/job-json-underlay-overlay.json index ebf4c1ed..63d1a85d 100644 --- a/qpdf/qtest/qpdf/job-json-underlay-overlay.json +++ b/qpdf/qtest/qpdf/job-json-underlay-overlay.json @@ -1,23 +1,15 @@ { - "input": { - "file": "20-pages.pdf", - "password": "owner" + "inputFile": "20-pages.pdf", + "password": "owner", + "outputFile": "a.pdf", + "staticId": true, + "decrypt": true, + "underlay": { + "file": "fxo-green.pdf" }, - "output": { - "file": "a.pdf", - "options": { - "staticId": true, - "decrypt": true - } - }, - "options": { - "underlay": { - "file": "fxo-green.pdf" - }, - "overlay": { - "file": "fxo-red.pdf", - "from": "1,2", - "repeat": "3" - } + "overlay": { + "file": "fxo-red.pdf", + "from": "1,2", + "repeat": "3" } } diff --git a/qpdf/qtest/qpdf/job-partial.json b/qpdf/qtest/qpdf/job-partial.json index ff2587c1..60215235 100644 --- a/qpdf/qtest/qpdf/job-partial.json +++ b/qpdf/qtest/qpdf/job-partial.json @@ -1,12 +1,8 @@ { - "output": { - "options": { - "encrypt": { - "userPassword": "", - "ownerPassword": "", - "256bit": { - } - } + "encrypt": { + "userPassword": "", + "ownerPassword": "", + "256bit": { } } } diff --git a/qpdf/qtest/qpdf/job-show-encryption.json b/qpdf/qtest/qpdf/job-show-encryption.json index 0a785ec6..08caf42c 100644 --- a/qpdf/qtest/qpdf/job-show-encryption.json +++ b/qpdf/qtest/qpdf/job-show-encryption.json @@ -1,5 +1,3 @@ { - "inspect": { - "showEncryption": true - } + "showEncryption": true }