aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-05-07 23:17:27 +0200
committerJay Berkenbilt <ejb@ql.org>2022-05-08 19:45:20 +0200
commite9390aeaaa3d4a6c6af5478bfd7a5fd6b2373087 (patch)
treeb3a2e8728a46fabba362c0e7458994da6219fe91 /libqpdf
parent2e87d593eb2f593807c34e7baa66b77bb039b996 (diff)
downloadqpdf-e9390aeaaa3d4a6c6af5478bfd7a5fd6b2373087.tar.zst
Add --to-json option
Diffstat (limited to 'libqpdf')
-rw-r--r--libqpdf/QPDFJob_config.cc10
-rw-r--r--libqpdf/qpdf/auto_job_help.hh10
-rw-r--r--libqpdf/qpdf/auto_job_init.hh1
-rw-r--r--libqpdf/qpdf/auto_job_json_init.hh3
-rw-r--r--libqpdf/qpdf/auto_job_schema.hh1
5 files changed, 22 insertions, 3 deletions
diff --git a/libqpdf/QPDFJob_config.cc b/libqpdf/QPDFJob_config.cc
index d990de37..f69a8137 100644
--- a/libqpdf/QPDFJob_config.cc
+++ b/libqpdf/QPDFJob_config.cc
@@ -284,6 +284,16 @@ QPDFJob::Config::jsonStreamPrefix(std::string const& parameter)
}
QPDFJob::Config*
+QPDFJob::Config::toJson()
+{
+ json("latest");
+ jsonStreamData("inline");
+ jsonKey("qpdf");
+ decodeLevel("none");
+ return this;
+}
+
+QPDFJob::Config*
QPDFJob::Config::testJsonSchema()
{
o.m->test_json_schema = true;
diff --git a/libqpdf/qpdf/auto_job_help.hh b/libqpdf/qpdf/auto_job_help.hh
index 47210371..d04f48a6 100644
--- a/libqpdf/qpdf/auto_job_help.hh
+++ b/libqpdf/qpdf/auto_job_help.hh
@@ -798,6 +798,10 @@ depth in the JSON section of the manual. "version" may be a
specific version or "latest". Run qpdf --json-help for a
description of the generated JSON object.
)");
+ap.addOptionHelp("--to-json", "json", "serialize to JSON", R"(Shortcut for options useful for serializing PDF to JSON:
+--json=latest --json-stream-data=inline
+ --json-key=qpdf --decode-level=none
+)");
ap.addOptionHelp("--json-help", "json", "show format of JSON output", R"(Describe the format of the JSON output by writing to standard
output a JSON object with the same keys and with values
containing descriptive text.
@@ -839,14 +843,14 @@ ap.addOptionHelp("--static-id", "testing", "use a fixed document ID", R"(Use a f
testing only. Never use it for production files. See also
qpdf --help=--deterministic-id.
)");
+}
+static void add_help_8(QPDFArgParser& ap)
+{
ap.addOptionHelp("--static-aes-iv", "testing", "use a fixed AES vector", R"(Use a static initialization vector for AES-CBC. This is intended
for testing only so that output files can be reproducible. Never
use it for production files. This option is not secure since it
significantly weakens the encryption.
)");
-}
-static void add_help_8(QPDFArgParser& ap)
-{
ap.addOptionHelp("--linearize-pass1", "testing", "save pass 1 of linearization", R"(--linearize-pass1=file
Write the first pass of linearization to the named file. The
diff --git a/libqpdf/qpdf/auto_job_init.hh b/libqpdf/qpdf/auto_job_init.hh
index 5c13275c..f3ec1db6 100644
--- a/libqpdf/qpdf/auto_job_init.hh
+++ b/libqpdf/qpdf/auto_job_init.hh
@@ -79,6 +79,7 @@ this->ap.addBare("static-id", [this](){c_main->staticId();});
this->ap.addBare("suppress-password-recovery", [this](){c_main->suppressPasswordRecovery();});
this->ap.addBare("suppress-recovery", [this](){c_main->suppressRecovery();});
this->ap.addBare("test-json-schema", [this](){c_main->testJsonSchema();});
+this->ap.addBare("to-json", [this](){c_main->toJson();});
this->ap.addBare("underlay", b(&ArgParser::argUnderlay));
this->ap.addBare("verbose", [this](){c_main->verbose();});
this->ap.addBare("warning-exit-0", [this](){c_main->warningExit0();});
diff --git a/libqpdf/qpdf/auto_job_json_init.hh b/libqpdf/qpdf/auto_job_json_init.hh
index c73eb3a7..cb349efc 100644
--- a/libqpdf/qpdf/auto_job_json_init.hh
+++ b/libqpdf/qpdf/auto_job_json_init.hh
@@ -259,6 +259,9 @@ popHandler(); // key: jsonStreamData
pushKey("jsonStreamPrefix");
addParameter([this](std::string const& p) { c_main->jsonStreamPrefix(p); });
popHandler(); // key: jsonStreamPrefix
+pushKey("toJson");
+addBare([this]() { c_main->toJson(); });
+popHandler(); // key: toJson
pushKey("allowWeakCrypto");
addBare([this]() { c_main->allowWeakCrypto(); });
popHandler(); // key: allowWeakCrypto
diff --git a/libqpdf/qpdf/auto_job_schema.hh b/libqpdf/qpdf/auto_job_schema.hh
index c2310961..666b7260 100644
--- a/libqpdf/qpdf/auto_job_schema.hh
+++ b/libqpdf/qpdf/auto_job_schema.hh
@@ -86,6 +86,7 @@ static constexpr char const* JOB_SCHEMA_DATA = R"({
],
"jsonStreamData": "how to handle streams in json output",
"jsonStreamPrefix": "prefix for json stream data files",
+ "toJson": "serialize to JSON",
"allowWeakCrypto": "allow insecure cryptographic algorithms",
"keepFilesOpen": "manage keeping multiple files open",
"keepFilesOpenThreshold": "set threshold for keepFilesOpen",