Commit 4927e0493ed0bdbae428fd3f3720126838e69935
Committed by
GitHub
Merge pull request #1419 from jberkenbilt/rotate-json
Allow rotate as array in job JSON (fixes #1401)
Showing
9 changed files
with
39 additions
and
6 deletions
job.sums
| @@ -7,13 +7,13 @@ include/qpdf/auto_job_c_enc.hh 28446f3c32153a52afa239ea40503e6cc8ac2c026813526a3 | @@ -7,13 +7,13 @@ include/qpdf/auto_job_c_enc.hh 28446f3c32153a52afa239ea40503e6cc8ac2c026813526a3 | ||
| 7 | include/qpdf/auto_job_c_main.hh 48e8ea475e8a8f4c96de86bdad10dff83a263deccc3798c8bed7f5e0e070a037 | 7 | include/qpdf/auto_job_c_main.hh 48e8ea475e8a8f4c96de86bdad10dff83a263deccc3798c8bed7f5e0e070a037 |
| 8 | include/qpdf/auto_job_c_pages.hh 09ca15649cc94fdaf6d9bdae28a20723f2a66616bf15aa86d83df31051d82506 | 8 | include/qpdf/auto_job_c_pages.hh 09ca15649cc94fdaf6d9bdae28a20723f2a66616bf15aa86d83df31051d82506 |
| 9 | include/qpdf/auto_job_c_uo.hh 9c2f98a355858dd54d0bba444b73177a59c9e56833e02fa6406f429c07f39e62 | 9 | include/qpdf/auto_job_c_uo.hh 9c2f98a355858dd54d0bba444b73177a59c9e56833e02fa6406f429c07f39e62 |
| 10 | -job.yml ba9f24920c2221883b1d6d8e42f7ac7c78988063a0ca9181dc08abe9cde6f760 | 10 | +job.yml 9245e70c233dc2067827593403bd9e9feafc5aa0be6b12bb7b99a4b2cab84584 |
| 11 | libqpdf/qpdf/auto_job_decl.hh 34ba07d3891c3e5cdd8712f991e508a0652c9db314c5d5bcdf4421b76e6f6e01 | 11 | libqpdf/qpdf/auto_job_decl.hh 34ba07d3891c3e5cdd8712f991e508a0652c9db314c5d5bcdf4421b76e6f6e01 |
| 12 | libqpdf/qpdf/auto_job_help.hh 03bdaab05f84b16bfb15ad7993a4655b7dc14af070fa97fe3035943726d4b258 | 12 | libqpdf/qpdf/auto_job_help.hh 03bdaab05f84b16bfb15ad7993a4655b7dc14af070fa97fe3035943726d4b258 |
| 13 | libqpdf/qpdf/auto_job_init.hh 029d929f930f60b4055796c8c4ce2ed625f861316ac738ab638579eca46b2472 | 13 | libqpdf/qpdf/auto_job_init.hh 029d929f930f60b4055796c8c4ce2ed625f861316ac738ab638579eca46b2472 |
| 14 | -libqpdf/qpdf/auto_job_json_decl.hh 843892c8e8652a86b7eb573893ef24050b7f36fe313f7251874be5cd4cdbe3fd | ||
| 15 | -libqpdf/qpdf/auto_job_json_init.hh b883f3768c8367327ea1f17e8ca503178be62a9cede316bf7ad96c0fafee5513 | ||
| 16 | -libqpdf/qpdf/auto_job_schema.hh 6d28db327dd19e0a7da375c681ecea7965513fa4b5d2349a80089b057f8c02d8 | 14 | +libqpdf/qpdf/auto_job_json_decl.hh 04965f6321e54b8b3b1dd2ca101d763a22ab44fa81c69e4b6fc0fd6bb7f50f92 |
| 15 | +libqpdf/qpdf/auto_job_json_init.hh 42b402305b52fc217453206c0a372303d0b59d4d4227bb564b4fa639257d4411 | ||
| 16 | +libqpdf/qpdf/auto_job_schema.hh 2d3c163c74498b638a13931eed71c2a4dc6b155a9d3e2c1b740070fac4293737 | ||
| 17 | manual/_ext/qpdf.py 6add6321666031d55ed4aedf7c00e5662bba856dfcd66ccb526563bffefbb580 | 17 | manual/_ext/qpdf.py 6add6321666031d55ed4aedf7c00e5662bba856dfcd66ccb526563bffefbb580 |
| 18 | manual/cli.rst 1094662a10db21528fd151739a9779a4504ebac75b483a11a53d42ab0430ee42 | 18 | manual/cli.rst 1094662a10db21528fd151739a9779a4504ebac75b483a11a53d42ab0430ee42 |
| 19 | manual/qpdf.1 c7d03b8b544b0c3b2a74149d746596d4564aefff50a53980e435aa5c841f7bed | 19 | manual/qpdf.1 c7d03b8b544b0c3b2a74149d746596d4564aefff50a53980e435aa5c841f7bed |
job.yml
libqpdf/QPDFJob_json.cc
| @@ -590,6 +590,18 @@ Handlers::setupUnderlayPassword() | @@ -590,6 +590,18 @@ Handlers::setupUnderlayPassword() | ||
| 590 | } | 590 | } |
| 591 | 591 | ||
| 592 | void | 592 | void |
| 593 | +Handlers::beginRotateArray(JSON) | ||
| 594 | +{ | ||
| 595 | + // nothing needed | ||
| 596 | +} | ||
| 597 | + | ||
| 598 | +void | ||
| 599 | +Handlers::endRotateArray() | ||
| 600 | +{ | ||
| 601 | + // nothing needed | ||
| 602 | +} | ||
| 603 | + | ||
| 604 | +void | ||
| 593 | Handlers::setupSetPageLabels() | 605 | Handlers::setupSetPageLabels() |
| 594 | { | 606 | { |
| 595 | accumulated_args.clear(); | 607 | accumulated_args.clear(); |
libqpdf/qpdf/auto_job_json_decl.hh
| @@ -43,6 +43,8 @@ void beginPages(JSON); | @@ -43,6 +43,8 @@ void beginPages(JSON); | ||
| 43 | void endPages(); | 43 | void endPages(); |
| 44 | void setupPagesFile(); | 44 | void setupPagesFile(); |
| 45 | void setupPagesPassword(); | 45 | void setupPagesPassword(); |
| 46 | +void beginRotateArray(JSON); | ||
| 47 | +void endRotateArray(); | ||
| 46 | void beginSetPageLabelsArray(JSON); | 48 | void beginSetPageLabelsArray(JSON); |
| 47 | void endSetPageLabelsArray(); | 49 | void endSetPageLabelsArray(); |
| 48 | void setupSetPageLabels(); | 50 | void setupSetPageLabels(); |
libqpdf/qpdf/auto_job_json_init.hh
| @@ -428,7 +428,9 @@ pushKey("reportMemoryUsage"); | @@ -428,7 +428,9 @@ pushKey("reportMemoryUsage"); | ||
| 428 | addBare([this]() { c_main->reportMemoryUsage(); }); | 428 | addBare([this]() { c_main->reportMemoryUsage(); }); |
| 429 | popHandler(); // key: reportMemoryUsage | 429 | popHandler(); // key: reportMemoryUsage |
| 430 | pushKey("rotate"); | 430 | pushKey("rotate"); |
| 431 | +beginArray(bindJSON(&Handlers::beginRotateArray), bindBare(&Handlers::endRotateArray)); // .rotate[] | ||
| 431 | addParameter([this](std::string const& p) { c_main->rotate(p); }); | 432 | addParameter([this](std::string const& p) { c_main->rotate(p); }); |
| 433 | +popHandler(); // array: .rotate[] | ||
| 432 | popHandler(); // key: rotate | 434 | popHandler(); // key: rotate |
| 433 | pushKey("setPageLabels"); | 435 | pushKey("setPageLabels"); |
| 434 | beginArray(bindJSON(&Handlers::beginSetPageLabelsArray), bindBare(&Handlers::endSetPageLabelsArray)); // .setPageLabels[] | 436 | beginArray(bindJSON(&Handlers::beginSetPageLabelsArray), bindBare(&Handlers::endSetPageLabelsArray)); // .setPageLabels[] |
libqpdf/qpdf/auto_job_schema.hh
| @@ -150,7 +150,9 @@ static constexpr char const* JOB_SCHEMA_DATA = R"({ | @@ -150,7 +150,9 @@ static constexpr char const* JOB_SCHEMA_DATA = R"({ | ||
| 150 | "removePageLabels": "remove explicit page numbers", | 150 | "removePageLabels": "remove explicit page numbers", |
| 151 | "removeStructure": "remove metadata", | 151 | "removeStructure": "remove metadata", |
| 152 | "reportMemoryUsage": "best effort report of memory usage", | 152 | "reportMemoryUsage": "best effort report of memory usage", |
| 153 | - "rotate": "rotate pages", | 153 | + "rotate": [ |
| 154 | + "rotate pages" | ||
| 155 | + ], | ||
| 154 | "setPageLabels": [ | 156 | "setPageLabels": [ |
| 155 | "number pages for the entire document" | 157 | "number pages for the entire document" |
| 156 | ], | 158 | ], |
manual/release-notes.rst
| @@ -29,6 +29,9 @@ more detail. | @@ -29,6 +29,9 @@ more detail. | ||
| 29 | - Fix two object stream error/warning messages that reported the wrong | 29 | - Fix two object stream error/warning messages that reported the wrong |
| 30 | object id. | 30 | object id. |
| 31 | 31 | ||
| 32 | + - Accept an array for ``rotate`` in qpdf job JSON since it is a | ||
| 33 | + repeatable option. | ||
| 34 | + | ||
| 32 | - CLI Enhancements | 35 | - CLI Enhancements |
| 33 | 36 | ||
| 34 | - New :qpdf:ref:`--remove-structure` option to exclude the document | 37 | - New :qpdf:ref:`--remove-structure` option to exclude the document |
qpdf/qtest/qpdf/rotate-multi.json
0 → 100644
qpdf/qtest/rotate-pages.test
| @@ -14,7 +14,7 @@ cleanup(); | @@ -14,7 +14,7 @@ cleanup(); | ||
| 14 | 14 | ||
| 15 | my $td = new TestDriver('rotate-pages'); | 15 | my $td = new TestDriver('rotate-pages'); |
| 16 | 16 | ||
| 17 | -my $n_tests = 21; | 17 | +my $n_tests = 22; |
| 18 | 18 | ||
| 19 | # Do absolute, positive, and negative on ranges that include | 19 | # Do absolute, positive, and negative on ranges that include |
| 20 | # inherited and non-inherited. | 20 | # inherited and non-inherited. |
| @@ -38,6 +38,10 @@ $td->runtest("page rotation (>270)", | @@ -38,6 +38,10 @@ $td->runtest("page rotation (>270)", | ||
| 38 | " --rotate=900:2,5,12-13" . | 38 | " --rotate=900:2,5,12-13" . |
| 39 | " --rotate=-1890:3,15,17,18"}, | 39 | " --rotate=-1890:3,15,17,18"}, |
| 40 | {$td->STRING => "", $td->EXIT_STATUS => 0}); | 40 | {$td->STRING => "", $td->EXIT_STATUS => 0}); |
| 41 | +$td->runtest("job json multiple page rotation", | ||
| 42 | + {$td->COMMAND => "qpdf --static-id to-rotate.pdf a.pdf" . | ||
| 43 | + " --job-json-file=rotate-multi.json"}, | ||
| 44 | + {$td->STRING => "", $td->EXIT_STATUS => 0}); | ||
| 41 | $td->runtest("check output", | 45 | $td->runtest("check output", |
| 42 | {$td->COMMAND => "qpdf-test-compare a.pdf rotated.pdf"}, | 46 | {$td->COMMAND => "qpdf-test-compare a.pdf rotated.pdf"}, |
| 43 | {$td->FILE => "rotated.pdf", $td->EXIT_STATUS => 0}); | 47 | {$td->FILE => "rotated.pdf", $td->EXIT_STATUS => 0}); |