Commit 08e3050d5f1608d744daafb8b6b39fe6ccea65ed
1 parent
a0e70b37
Automated changes for --set-page-labels
This commit contains the changes from generate_auto_job based on manual changes from the previous commit.
Showing
9 changed files
with
120 additions
and
21 deletions
include/qpdf/auto_job_c_set_page_labels.hh
0 → 100644
job.sums
| ... | ... | @@ -7,14 +7,14 @@ include/qpdf/auto_job_c_enc.hh 28446f3c32153a52afa239ea40503e6cc8ac2c026813526a3 |
| 7 | 7 | include/qpdf/auto_job_c_main.hh dbfc221d1533120d1aa9c361d8d2483dea5fcb1c0fd95144d98d305e64ed32a6 |
| 8 | 8 | include/qpdf/auto_job_c_pages.hh b3cc0f21029f6d89efa043dcdbfa183cb59325b6506001c18911614fe8e568ec |
| 9 | 9 | include/qpdf/auto_job_c_uo.hh ae21b69a1efa9333050f4833d465f6daff87e5b38e5106e49bbef5d4132e4ed1 |
| 10 | -job.yml 4f89fc7b622df897d30d403d8035aa36fc7de8d8c43042c736e0300d904cb05c | |
| 11 | -libqpdf/qpdf/auto_job_decl.hh 9c6f701c29f3f764d620186bed92685a2edf2e4d11e4f4532862c05470cfc4d2 | |
| 12 | -libqpdf/qpdf/auto_job_help.hh ea0d0cdebeb190d305bd5f9bca85a4430dbcfa0881ac9be839216b878765b379 | |
| 13 | -libqpdf/qpdf/auto_job_init.hh b4c2b3724fba61f1206fd3bae81951636852592f67a63ef9539839c2c5995065 | |
| 14 | -libqpdf/qpdf/auto_job_json_decl.hh 06caa46eaf71db8a50c046f91866baa8087745a9474319fb7c86d92634cc8297 | |
| 15 | -libqpdf/qpdf/auto_job_json_init.hh f5acb9aa103131cb68dec0e12c4d237a6459bdb49b24773c24f0c2724a462b8f | |
| 16 | -libqpdf/qpdf/auto_job_schema.hh b53c006fec2e75b1b73588d242d49a32f7d3db820b1541de106c5d4c27fbb4d9 | |
| 10 | +job.yml 8ad309ac41520b34692bcf22fd5c2ef4810ff69562aed606bd57df7bf589bc43 | |
| 11 | +libqpdf/qpdf/auto_job_decl.hh 1e8d73891bd1f0b5df5a5ca7405fb76d2d0fd024941b8c1b86489f1b5f9c5772 | |
| 12 | +libqpdf/qpdf/auto_job_help.hh 8c172913920a5273e04dc4d2059f2d78fc475960ac1738271357056beb02dd27 | |
| 13 | +libqpdf/qpdf/auto_job_init.hh ea272fd6a6a5e4d23cabd70a7b7d5ecc543b6304008c656dcba2d353d378efc2 | |
| 14 | +libqpdf/qpdf/auto_job_json_decl.hh 10ffb0d0e5ca09809a5d5d78f66dee393dfd2653a23441436465fd5ace151880 | |
| 15 | +libqpdf/qpdf/auto_job_json_init.hh 9c3839877ab3b15a47e92086f0b5616da33fd4970538cc423d3b0a7ff33ce66a | |
| 16 | +libqpdf/qpdf/auto_job_schema.hh a882939b202d48ad1c0751c094f671ad7aad0fc04c3a4446ad83675db365c8a2 | |
| 17 | 17 | manual/_ext/qpdf.py 6add6321666031d55ed4aedf7c00e5662bba856dfcd66ccb526563bffefbb580 |
| 18 | -manual/cli.rst d75ae0584df2217827d6663da1a83bfa78e70599156ef2ca9cfb1236833ffd22 | |
| 19 | -manual/qpdf.1 738dc9b732ad4c880d034b99f957077628fde1d0006943aaf813e98f8e2f9635 | |
| 18 | +manual/cli.rst 38ff5e0e3a6bc01eab0b7d9f3fd22bfe4ec90ad5dcd48ba8be8412177c7bbf61 | |
| 19 | +manual/qpdf.1 c89ac263ffb697c7c1f6233fa54bd6403a455a989b550f78868c284947d707a3 | |
| 20 | 20 | manual/qpdf.1.in 436ecc85d45c4c9e2dbd1725fb7f0177fb627179469f114561adf3cb6cbb677b | ... | ... |
libqpdf/qpdf/auto_job_decl.hh
| ... | ... | @@ -13,6 +13,7 @@ static constexpr char const* O_256_BIT_ENCRYPTION = "256-bit encryption"; |
| 13 | 13 | static constexpr char const* O_UNDERLAY_OVERLAY = "underlay/overlay"; |
| 14 | 14 | static constexpr char const* O_ATTACHMENT = "attachment"; |
| 15 | 15 | static constexpr char const* O_COPY_ATTACHMENT = "copy attachment"; |
| 16 | +static constexpr char const* O_SET_PAGE_LABELS = "set page labels"; | |
| 16 | 17 | |
| 17 | 18 | void argVersion(); |
| 18 | 19 | void argCopyright(); |
| ... | ... | @@ -27,6 +28,7 @@ void argEncrypt(); |
| 27 | 28 | void argOverlay(); |
| 28 | 29 | void argPages(); |
| 29 | 30 | void argReplaceInput(); |
| 31 | +void argSetPageLabels(); | |
| 30 | 32 | void argUnderlay(); |
| 31 | 33 | void argPagesPositional(std::string const&); |
| 32 | 34 | void argPagesPassword(std::string const&); |
| ... | ... | @@ -45,3 +47,5 @@ void argAttPositional(std::string const&); |
| 45 | 47 | void argEndAttachment(); |
| 46 | 48 | void argCopyAttPositional(std::string const&); |
| 47 | 49 | void argEndCopyAttachment(); |
| 50 | +void argPageLabelsPositional(std::string const&); | |
| 51 | +void argEndSetPageLabels(); | ... | ... |
libqpdf/qpdf/auto_job_help.hh
| ... | ... | @@ -402,6 +402,41 @@ ap.addOptionHelp("--keep-inline-images", "modification", "exclude inline images |
| 402 | 402 | )"); |
| 403 | 403 | ap.addOptionHelp("--remove-page-labels", "modification", "remove explicit page numbers", R"(Exclude page labels (explicit page numbers) from the output file. |
| 404 | 404 | )"); |
| 405 | +ap.addOptionHelp("--set-page-labels", "modification", "number pages for the entire document", R"(--set-page-labels label-spec ... -- | |
| 406 | + | |
| 407 | +Set page labels (explicit page numbers) for the entire file. | |
| 408 | +Each label-spec has the form | |
| 409 | + | |
| 410 | +first-page:[type][/start[/prefix]] | |
| 411 | + | |
| 412 | +where | |
| 413 | + | |
| 414 | +- "first-page" represents a sequential page number using the | |
| 415 | + same format as page ranges: a number, a number preceded by "r" | |
| 416 | + to indicate counting from the end, or "z" indicating the last | |
| 417 | + page | |
| 418 | +- "type" is one of | |
| 419 | + - D: Arabic numerals (digits) | |
| 420 | + - A: Upper-case alphabetic characters | |
| 421 | + - a: Lower-case alphabetic characters | |
| 422 | + - R: Upper-case Roman numerals | |
| 423 | + - r: Lower-case Roman numerals | |
| 424 | + - omitted: the page number does not appear, though the prefix, | |
| 425 | + if specified will still appear | |
| 426 | +- "prefix"` may be any string and is prepended to each page | |
| 427 | + label | |
| 428 | + | |
| 429 | +A given page label spec causes pages to be numbered according to | |
| 430 | +that scheme starting with first-page and continuing until the | |
| 431 | +next label spec or the end of the document. If you want to omit | |
| 432 | +numbering starting at a certain page, you can use first-page: as | |
| 433 | +the spec. | |
| 434 | + | |
| 435 | +Example: "1:r 5:D" would number the first four pages i through | |
| 436 | +iv, then the remaining pages with Arabic numerals starting with | |
| 437 | +1 and continuing sequentially until the end of the document. For | |
| 438 | +additional examples, please consult the manual. | |
| 439 | +)"); | |
| 405 | 440 | ap.addHelpTopic("encryption", "create encrypted files", R"(Create encrypted files. Usage: |
| 406 | 441 | |
| 407 | 442 | --encrypt \ |
| ... | ... | @@ -485,13 +520,13 @@ ap.addOptionHelp("--user-password", "encryption", "specify user password", R"(-- |
| 485 | 520 | |
| 486 | 521 | Set the user password of the encrypted file. |
| 487 | 522 | )"); |
| 523 | +} | |
| 524 | +static void add_help_5(QPDFArgParser& ap) | |
| 525 | +{ | |
| 488 | 526 | ap.addOptionHelp("--owner-password", "encryption", "specify owner password", R"(--owner-password=owner-password |
| 489 | 527 | |
| 490 | 528 | Set the owner password of the encrypted file. |
| 491 | 529 | )"); |
| 492 | -} | |
| 493 | -static void add_help_5(QPDFArgParser& ap) | |
| 494 | -{ | |
| 495 | 530 | ap.addOptionHelp("--bits", "encryption", "specify encryption key length", R"(--bits={48|128|256} |
| 496 | 531 | |
| 497 | 532 | Specify the encryption key length. For best security, always use |
| ... | ... | @@ -665,15 +700,15 @@ the destination pages. See qpdf --help=page-ranges for help |
| 665 | 700 | with the page range syntax. The page range may be omitted |
| 666 | 701 | if --repeat is used. |
| 667 | 702 | )"); |
| 703 | +} | |
| 704 | +static void add_help_6(QPDFArgParser& ap) | |
| 705 | +{ | |
| 668 | 706 | ap.addOptionHelp("--repeat", "overlay-underlay", "overlay/underlay pages to repeat", R"(--repeat=page-range |
| 669 | 707 | |
| 670 | 708 | Specify pages from the overlay/underlay that are repeated after |
| 671 | 709 | "from" pages have been exhausted. See qpdf --help=page-ranges |
| 672 | 710 | for help with the page range syntax. |
| 673 | 711 | )"); |
| 674 | -} | |
| 675 | -static void add_help_6(QPDFArgParser& ap) | |
| 676 | -{ | |
| 677 | 712 | ap.addHelpTopic("attachments", "work with embedded files", R"(It is possible to list, add, or delete embedded files (also known |
| 678 | 713 | as attachments) and to copy attachments from other files. See help |
| 679 | 714 | on individual options for details. Run qpdf --help=add-attachment |
| ... | ... | @@ -782,6 +817,9 @@ ap.addOptionHelp("--requires-password", "inspection", "silently test a file's pa |
| 782 | 817 | 2: the file is not encrypted |
| 783 | 818 | 3: the file is encrypted, and correct password (if any) has been supplied |
| 784 | 819 | )"); |
| 820 | +} | |
| 821 | +static void add_help_7(QPDFArgParser& ap) | |
| 822 | +{ | |
| 785 | 823 | ap.addOptionHelp("--check", "inspection", "partially check whether PDF is valid", R"(Check the structure of the PDF file as well as a number of other |
| 786 | 824 | aspects of the file, and write information about the file to |
| 787 | 825 | standard output. Note that qpdf does not perform any validation |
| ... | ... | @@ -789,9 +827,6 @@ of the actual PDF page content or semantic correctness of the |
| 789 | 827 | PDF file. It merely checks that the PDF file is syntactically |
| 790 | 828 | valid. See also qpdf --help=exit-status. |
| 791 | 829 | )"); |
| 792 | -} | |
| 793 | -static void add_help_7(QPDFArgParser& ap) | |
| 794 | -{ | |
| 795 | 830 | ap.addOptionHelp("--show-encryption", "inspection", "information about encrypted files", R"(Show document encryption parameters. Also show the document's |
| 796 | 831 | user password if the owner password is given and the file was |
| 797 | 832 | encrypted using older encryption formats that allow user |
| ... | ... | @@ -872,6 +907,9 @@ This option is repeatable. If given, only specified objects will |
| 872 | 907 | be shown in the "objects" key of the JSON output. Otherwise, all |
| 873 | 908 | objects will be shown. |
| 874 | 909 | )"); |
| 910 | +} | |
| 911 | +static void add_help_8(QPDFArgParser& ap) | |
| 912 | +{ | |
| 875 | 913 | ap.addOptionHelp("--json-stream-data", "json", "how to handle streams in json output", R"(--json-stream-data={none|inline|file} |
| 876 | 914 | |
| 877 | 915 | When used with --json, this option controls whether streams in |
| ... | ... | @@ -883,9 +921,6 @@ object number. The prefix can be overridden with |
| 883 | 921 | when --json-output is specified, in which case the default is |
| 884 | 922 | "inline". |
| 885 | 923 | )"); |
| 886 | -} | |
| 887 | -static void add_help_8(QPDFArgParser& ap) | |
| 888 | -{ | |
| 889 | 924 | ap.addOptionHelp("--json-stream-prefix", "json", "prefix for json stream data files", R"(--json-stream-prefix=file-prefix |
| 890 | 925 | |
| 891 | 926 | When used with --json-stream-data=file, --json-stream-data=file-prefix | ... | ... |
libqpdf/qpdf/auto_job_init.hh
| ... | ... | @@ -73,6 +73,7 @@ this->ap.addBare("replace-input", b(&ArgParser::argReplaceInput)); |
| 73 | 73 | this->ap.addBare("report-memory-usage", [this](){c_main->reportMemoryUsage();}); |
| 74 | 74 | this->ap.addBare("requires-password", [this](){c_main->requiresPassword();}); |
| 75 | 75 | this->ap.addBare("remove-restrictions", [this](){c_main->removeRestrictions();}); |
| 76 | +this->ap.addBare("set-page-labels", b(&ArgParser::argSetPageLabels)); | |
| 76 | 77 | this->ap.addBare("show-encryption", [this](){c_main->showEncryption();}); |
| 77 | 78 | this->ap.addBare("show-encryption-key", [this](){c_main->showEncryptionKey();}); |
| 78 | 79 | this->ap.addBare("show-linearization", [this](){c_main->showLinearization();}); |
| ... | ... | @@ -180,3 +181,5 @@ this->ap.registerOptionTable("copy attachment", b(&ArgParser::argEndCopyAttachme |
| 180 | 181 | this->ap.addPositional(p(&ArgParser::argCopyAttPositional)); |
| 181 | 182 | this->ap.addRequiredParameter("prefix", [this](std::string const& x){c_copy_att->prefix(x);}, "prefix"); |
| 182 | 183 | this->ap.addRequiredParameter("password", [this](std::string const& x){c_copy_att->password(x);}, "password"); |
| 184 | +this->ap.registerOptionTable("set page labels", b(&ArgParser::argEndSetPageLabels)); | |
| 185 | +this->ap.addPositional(p(&ArgParser::argPageLabelsPositional)); | ... | ... |
libqpdf/qpdf/auto_job_json_decl.hh
| ... | ... | @@ -44,6 +44,9 @@ void endPages(); |
| 44 | 44 | void setupPagesFile(); |
| 45 | 45 | void setupPagesPassword(); |
| 46 | 46 | void setupPagesRange(); |
| 47 | +void beginSetPageLabelsArray(JSON); | |
| 48 | +void endSetPageLabelsArray(); | |
| 49 | +void setupSetPageLabels(); | |
| 47 | 50 | void beginOverlay(JSON); |
| 48 | 51 | void endOverlay(); |
| 49 | 52 | void setupOverlayFile(); | ... | ... |
libqpdf/qpdf/auto_job_json_init.hh
| ... | ... | @@ -421,6 +421,11 @@ popHandler(); // key: reportMemoryUsage |
| 421 | 421 | pushKey("rotate"); |
| 422 | 422 | addParameter([this](std::string const& p) { c_main->rotate(p); }); |
| 423 | 423 | popHandler(); // key: rotate |
| 424 | +pushKey("setPageLabels"); | |
| 425 | +beginArray(bindJSON(&Handlers::beginSetPageLabelsArray), bindBare(&Handlers::endSetPageLabelsArray)); // .setPageLabels[] | |
| 426 | +setupSetPageLabels(); | |
| 427 | +popHandler(); // array: .setPageLabels[] | |
| 428 | +popHandler(); // key: setPageLabels | |
| 424 | 429 | pushKey("overlay"); |
| 425 | 430 | beginDict(bindJSON(&Handlers::beginOverlay), bindBare(&Handlers::endOverlay)); // .overlay |
| 426 | 431 | pushKey("file"); | ... | ... |
libqpdf/qpdf/auto_job_schema.hh
| ... | ... | @@ -148,6 +148,9 @@ static constexpr char const* JOB_SCHEMA_DATA = R"({ |
| 148 | 148 | "removePageLabels": "remove explicit page numbers", |
| 149 | 149 | "reportMemoryUsage": "best effort report of memory usage", |
| 150 | 150 | "rotate": "rotate pages", |
| 151 | + "setPageLabels": [ | |
| 152 | + "number pages for the entire document" | |
| 153 | + ], | |
| 151 | 154 | "overlay": { |
| 152 | 155 | "file": "source file for overlay", |
| 153 | 156 | "password": "password for encrypted file", | ... | ... |
manual/qpdf.1
| ... | ... | @@ -516,6 +516,45 @@ Prevent inline images from being considered by --optimize-images. |
| 516 | 516 | .TP |
| 517 | 517 | .B --remove-page-labels \-\- remove explicit page numbers |
| 518 | 518 | Exclude page labels (explicit page numbers) from the output file. |
| 519 | +.TP | |
| 520 | +.B --set-page-labels \-\- number pages for the entire document | |
| 521 | +--set-page-labels label-spec ... -- | |
| 522 | + | |
| 523 | +Set page labels (explicit page numbers) for the entire file. | |
| 524 | +Each label-spec has the form | |
| 525 | + | |
| 526 | +first-page:[type][/start[/prefix]] | |
| 527 | + | |
| 528 | +where | |
| 529 | + | |
| 530 | +.IP \[bu] | |
| 531 | +"first-page" represents a sequential page number using the | |
| 532 | +same format as page ranges: a number, a number preceded by "r" | |
| 533 | +to indicate counting from the end, or "z" indicating the last | |
| 534 | +page | |
| 535 | +.IP \[bu] | |
| 536 | +"type" is one of | |
| 537 | +- D: Arabic numerals (digits) | |
| 538 | +- A: Upper-case alphabetic characters | |
| 539 | +- a: Lower-case alphabetic characters | |
| 540 | +- R: Upper-case Roman numerals | |
| 541 | +- r: Lower-case Roman numerals | |
| 542 | +- omitted: the page number does not appear, though the prefix, | |
| 543 | + if specified will still appear | |
| 544 | +.IP \[bu] | |
| 545 | +"prefix"` may be any string and is prepended to each page | |
| 546 | +label | |
| 547 | + | |
| 548 | +A given page label spec causes pages to be numbered according to | |
| 549 | +that scheme starting with first-page and continuing until the | |
| 550 | +next label spec or the end of the document. If you want to omit | |
| 551 | +numbering starting at a certain page, you can use first-page: as | |
| 552 | +the spec. | |
| 553 | + | |
| 554 | +Example: "1:r 5:D" would number the first four pages i through | |
| 555 | +iv, then the remaining pages with Arabic numerals starting with | |
| 556 | +1 and continuing sequentially until the end of the document. For | |
| 557 | +additional examples, please consult the manual. | |
| 519 | 558 | .SH ENCRYPTION (create encrypted files) |
| 520 | 559 | Create encrypted files. Usage: |
| 521 | 560 | ... | ... |