From 4fe2e06b4787ffb639f965ac840b51018308ec07 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sun, 8 May 2022 13:42:16 -0400 Subject: Add --create-from-json and --update-from-json arguments Also add stubs for top-level QPDF methods (createFromJSON, updateFromJSON) --- include/qpdf/QPDF.hh | 22 ++++++++++++++++++++++ include/qpdf/QPDFJob.hh | 4 ++++ include/qpdf/auto_job_c_main.hh | 1 + 3 files changed, 27 insertions(+) (limited to 'include') diff --git a/include/qpdf/QPDF.hh b/include/qpdf/QPDF.hh index bbbb896e..5cba93a8 100644 --- a/include/qpdf/QPDF.hh +++ b/include/qpdf/QPDF.hh @@ -110,6 +110,28 @@ class QPDF void processInputSource(std::shared_ptr, char const* password = 0); + // Create a PDF from an input source that contains JSON as written + // by qpdf --json (version 2 or higher). The JSON must be a + // complete representation of a PDF. See "QPDF JSON Format" in the + // manual for details. + QPDF_DLL + void + createFromJSON(std::string const& json_file); + QPDF_DLL + void + createFromJSON(std::shared_ptr); + + // Update a PDF from an input source that contains JSON in the + // same format as is written by qpdf --json (version 2 or higher). + // Objects in the PDF and not in the JSON are not modified. See + // "QPDF JSON Format" in the manual for details. + QPDF_DLL + void + updateFromJSON(std::string const& json_file); + QPDF_DLL + void + updateFromJSON(std::shared_ptr); + // Close or otherwise release the input source. Once this has been // called, no other methods of qpdf can be called safely except // for getWarnings and anyWarnings(). After this has been called, diff --git a/include/qpdf/QPDFJob.hh b/include/qpdf/QPDFJob.hh index da8d3fcb..a7d86337 100644 --- a/include/qpdf/QPDFJob.hh +++ b/include/qpdf/QPDFJob.hh @@ -323,6 +323,8 @@ class QPDFJob Config* outputFile(std::string const& filename); QPDF_DLL Config* replaceInput(); + QPDF_DLL + Config* createFromJson(std::string const& filename); QPDF_DLL std::shared_ptr copyAttachmentsFrom(); @@ -674,6 +676,8 @@ class QPDFJob bool check_requires_password; std::shared_ptr infilename; std::shared_ptr outfilename; + std::string create_from_json; + std::string update_from_json; }; std::shared_ptr m; }; diff --git a/include/qpdf/auto_job_c_main.hh b/include/qpdf/auto_job_c_main.hh index 42e30a70..cc1bf469 100644 --- a/include/qpdf/auto_job_c_main.hh +++ b/include/qpdf/auto_job_c_main.hh @@ -68,6 +68,7 @@ QPDF_DLL Config* rotate(std::string const& parameter); QPDF_DLL Config* showAttachment(std::string const& parameter); QPDF_DLL Config* showObject(std::string const& parameter); QPDF_DLL Config* jsonStreamPrefix(std::string const& parameter); +QPDF_DLL Config* updateFromJson(std::string const& parameter); QPDF_DLL Config* collate(std::string const& parameter); QPDF_DLL Config* collate(); QPDF_DLL Config* splitPages(std::string const& parameter); -- cgit v1.2.3-54-g00ecf