aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-07-24 22:54:48 +0200
committerJay Berkenbilt <ejb@ql.org>2022-07-31 16:32:55 +0200
commitbb96499b613265b3d9cf2146af09283a4b99ef13 (patch)
treeecf2ae2ac567a9df00729886bb8e3777348e8d5a /libqpdf
parent0e3d4cdc9753ae59d42ff8478b0769196899032b (diff)
downloadqpdf-bb96499b613265b3d9cf2146af09283a4b99ef13.tar.zst
Update docs and prepare QPDF::writeJSON for changes
Add additional parameters that will be needed to call QPDF::writeJSON in partial mode.
Diffstat (limited to 'libqpdf')
-rw-r--r--libqpdf/QPDFJob.cc2
-rw-r--r--libqpdf/QPDFJob_config.cc3
-rw-r--r--libqpdf/QPDF_json.cc10
-rw-r--r--libqpdf/qpdf/auto_job_help.hh16
4 files changed, 21 insertions, 10 deletions
diff --git a/libqpdf/QPDFJob.cc b/libqpdf/QPDFJob.cc
index 06e93704..ae717218 100644
--- a/libqpdf/QPDFJob.cc
+++ b/libqpdf/QPDFJob.cc
@@ -3381,6 +3381,8 @@ QPDFJob::writeJSON(QPDF& pdf)
pdf.writeJSON(
this->m->json_output,
fp.get(),
+ true,
+ true,
this->m->decode_level,
this->m->json_stream_data,
file_prefix,
diff --git a/libqpdf/QPDFJob_config.cc b/libqpdf/QPDFJob_config.cc
index 0192346e..6a500b5c 100644
--- a/libqpdf/QPDFJob_config.cc
+++ b/libqpdf/QPDFJob_config.cc
@@ -312,6 +312,9 @@ QPDFJob::Config::jsonOutput(std::string const& parameter)
if (!o.m->decode_level_set) {
o.m->decode_level = qpdf_dl_none;
}
+ if (o.m->json_keys.empty()) {
+ o.m->json_keys.insert("qpdf");
+ }
return this;
}
diff --git a/libqpdf/QPDF_json.cc b/libqpdf/QPDF_json.cc
index 59aac05e..81f21f8a 100644
--- a/libqpdf/QPDF_json.cc
+++ b/libqpdf/QPDF_json.cc
@@ -764,6 +764,8 @@ void
QPDF::writeJSON(
int version,
Pipeline* p,
+ bool complete,
+ bool first_key,
qpdf_stream_decode_level_e decode_level,
qpdf_json_stream_data_e json_stream_data,
std::string const& file_prefix,
@@ -818,7 +820,9 @@ QPDF::writeJSON(
}
JSON::writeDictionaryClose(p, first_object, 2);
JSON::writeDictionaryClose(p, first_qpdf, 1);
- JSON::writeDictionaryClose(p, first, 0);
- *p << "\n";
- p->finish();
+ if (complete) {
+ JSON::writeDictionaryClose(p, first, 0);
+ *p << "\n";
+ p->finish();
+ }
}
diff --git a/libqpdf/qpdf/auto_job_help.hh b/libqpdf/qpdf/auto_job_help.hh
index 5146ddae..6ade99f5 100644
--- a/libqpdf/qpdf/auto_job_help.hh
+++ b/libqpdf/qpdf/auto_job_help.hh
@@ -821,16 +821,18 @@ objects will be shown.
)");
ap.addOptionHelp("--json-stream-data", "json", "how to handle streams in json output", R"(--json-stream-data={none|inline|file}
-When used with --json-output, this option controls whether
-streams in json output should be omitted, written inline
-(base64-encoded) or written to a file. If "file" is chosen, the
-file will be the name of the output file appended with -nnn where
-nnn is the object number. The prefix can be overridden with
---json-stream-prefix.
+When used with --json, this option controls whether streams in
+json output should be omitted, written inline (base64-encoded)
+or written to a file. If "file" is chosen, the file will be the
+name of the output file appended with -nnn where nnn is the
+object number. The prefix can be overridden with
+--json-stream-prefix. The default is "none", except
+when --json-output is specified, in which case the default is
+"inline".
)");
ap.addOptionHelp("--json-stream-prefix", "json", "prefix for json stream data files", R"(--json-stream-prefix=file-prefix
-When used with --json-output, --json-stream-data=file-prefix
+When used with --json-stream-data=file, --json-stream-data=file-prefix
sets the prefix for stream data files, overriding the default,
which is to use the output file name. Whatever is given here
will be appended with -nnn to create the name of the file that