From 9c723aeb56351e20203f0c0058e5f718f44dee22 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Tue, 9 Jan 2024 13:25:04 -0500 Subject: Allow --file with --overlay and --underlay --- libqpdf/QPDFJob_json.cc | 6 ++++++ libqpdf/qpdf/auto_job_help.hh | 2 +- libqpdf/qpdf/auto_job_init.hh | 1 + libqpdf/qpdf/auto_job_json_decl.hh | 1 + libqpdf/qpdf/auto_job_json_init.hh | 2 +- libqpdf/qpdf/auto_job_schema.hh | 4 ++-- 6 files changed, 12 insertions(+), 4 deletions(-) (limited to 'libqpdf') diff --git a/libqpdf/QPDFJob_json.cc b/libqpdf/QPDFJob_json.cc index 5565ea93..797ee81d 100644 --- a/libqpdf/QPDFJob_json.cc +++ b/libqpdf/QPDFJob_json.cc @@ -486,6 +486,12 @@ Handlers::endPages() // nothing needed } +void +Handlers::setupPagesFile() +{ + addParameter([this](char const* p) { c_pages->file(p); }); +} + void Handlers::setupPagesPassword() { diff --git a/libqpdf/qpdf/auto_job_help.hh b/libqpdf/qpdf/auto_job_help.hh index a3572aed..903bdd56 100644 --- a/libqpdf/qpdf/auto_job_help.hh +++ b/libqpdf/qpdf/auto_job_help.hh @@ -695,7 +695,7 @@ underlaid on the primary output. Overlaid pages are drawn on top of the destination page and may obscure the page. Underlaid pages are drawn below the destination page. Usage: -{--overlay|--underlay} file +{--overlay|--underlay} [--file=]file [--password=password] [--to=page-range] [--from=[page-range]] diff --git a/libqpdf/qpdf/auto_job_init.hh b/libqpdf/qpdf/auto_job_init.hh index 401406db..ac42ea6a 100644 --- a/libqpdf/qpdf/auto_job_init.hh +++ b/libqpdf/qpdf/auto_job_init.hh @@ -166,6 +166,7 @@ this->ap.addChoices("modify-other", [this](std::string const& x){c_enc->modifyOt this->ap.addChoices("modify", [this](std::string const& x){c_enc->modify(x);}, true, modify128_choices); this->ap.registerOptionTable("underlay/overlay", b(&ArgParser::argEndUnderlayOverlay)); this->ap.addPositional(p(&ArgParser::argUOPositional)); +this->ap.addRequiredParameter("file", [this](std::string const& x){c_uo->file(x);}, "file"); this->ap.addRequiredParameter("to", [this](std::string const& x){c_uo->to(x);}, "page-range"); this->ap.addRequiredParameter("from", [this](std::string const& x){c_uo->from(x);}, "page-range"); this->ap.addRequiredParameter("repeat", [this](std::string const& x){c_uo->repeat(x);}, "page-range"); diff --git a/libqpdf/qpdf/auto_job_json_decl.hh b/libqpdf/qpdf/auto_job_json_decl.hh index b2ae4c1e..d7cb9595 100644 --- a/libqpdf/qpdf/auto_job_json_decl.hh +++ b/libqpdf/qpdf/auto_job_json_decl.hh @@ -41,6 +41,7 @@ void beginPagesArray(JSON); void endPagesArray(); void beginPages(JSON); void endPages(); +void setupPagesFile(); void setupPagesPassword(); void beginSetPageLabelsArray(JSON); void endSetPageLabelsArray(); diff --git a/libqpdf/qpdf/auto_job_json_init.hh b/libqpdf/qpdf/auto_job_json_init.hh index fb4d93b9..aaa1fb64 100644 --- a/libqpdf/qpdf/auto_job_json_init.hh +++ b/libqpdf/qpdf/auto_job_json_init.hh @@ -402,7 +402,7 @@ pushKey("pages"); beginArray(bindJSON(&Handlers::beginPagesArray), bindBare(&Handlers::endPagesArray)); // .pages[] beginDict(bindJSON(&Handlers::beginPages), bindBare(&Handlers::endPages)); // .pages pushKey("file"); -addParameter([this](std::string const& p) { c_pages->file(p); }); +setupPagesFile(); popHandler(); // key: file pushKey("password"); setupPagesPassword(); diff --git a/libqpdf/qpdf/auto_job_schema.hh b/libqpdf/qpdf/auto_job_schema.hh index bb4b04ea..507a54a4 100644 --- a/libqpdf/qpdf/auto_job_schema.hh +++ b/libqpdf/qpdf/auto_job_schema.hh @@ -152,14 +152,14 @@ static constexpr char const* JOB_SCHEMA_DATA = R"({ "number pages for the entire document" ], "overlay": { - "file": "source file for overlay", + "file": "source for pages", "password": "password for encrypted file", "from": "source pages for underlay/overlay", "repeat": "overlay/underlay pages to repeat", "to": "destination pages for underlay/overlay" }, "underlay": { - "file": "source file for underlay", + "file": "source for pages", "password": "password for encrypted file", "from": "source pages for underlay/overlay", "repeat": "overlay/underlay pages to repeat", -- cgit v1.2.3-54-g00ecf