aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-05-07 19:33:45 +0200
committerJay Berkenbilt <ejb@ql.org>2022-05-08 19:45:20 +0200
commitc76536dd9a150adb71fdcda11ee1a93f25128cc7 (patch)
tree03f68965ad1646f643d184b0435bd6706b42fcdc /include
parentbdfc4da5105c86f0dc63ed390da240306e6b4466 (diff)
downloadqpdf-c76536dd9a150adb71fdcda11ee1a93f25128cc7.tar.zst
Implement JSON v2 output
Diffstat (limited to 'include')
-rw-r--r--include/qpdf/Constants.h2
-rw-r--r--include/qpdf/QPDFJob.hh15
-rw-r--r--include/qpdf/QPDFObjectHandle.hh10
-rw-r--r--include/qpdf/auto_job_c_main.hh2
4 files changed, 25 insertions, 4 deletions
diff --git a/include/qpdf/Constants.h b/include/qpdf/Constants.h
index babf215c..d1fd969b 100644
--- a/include/qpdf/Constants.h
+++ b/include/qpdf/Constants.h
@@ -100,7 +100,7 @@ enum qpdf_stream_decode_level_e {
qpdf_dl_all /* also decode lossy filters */
};
/* For JSON encoding */
-enum qpdf_stream_data_json_e {
+enum qpdf_json_stream_data_e {
qpdf_sj_none = 0,
qpdf_sj_inline,
qpdf_sj_file,
diff --git a/include/qpdf/QPDFJob.hh b/include/qpdf/QPDFJob.hh
index f85c1ec7..da8d3fcb 100644
--- a/include/qpdf/QPDFJob.hh
+++ b/include/qpdf/QPDFJob.hh
@@ -515,12 +515,25 @@ class QPDFJob
std::set<QPDFObjGen> getWantedJSONObjects();
void doJSONObjects(Pipeline* p, bool& first, QPDF& pdf);
void doJSONObjectinfo(Pipeline* p, bool& first, QPDF& pdf);
+ void doJSONQpdf(Pipeline* p, bool& first, QPDF& pdf);
void doJSONPages(Pipeline* p, bool& first, QPDF& pdf);
void doJSONPageLabels(Pipeline* p, bool& first, QPDF& pdf);
void doJSONOutlines(Pipeline* p, bool& first, QPDF& pdf);
void doJSONAcroform(Pipeline* p, bool& first, QPDF& pdf);
void doJSONEncrypt(Pipeline* p, bool& first, QPDF& pdf);
void doJSONAttachments(Pipeline* p, bool& first, QPDF& pdf);
+ void doJSONStream(
+ Pipeline* p,
+ bool& first,
+ QPDF& pdf,
+ QPDFObjectHandle& obj,
+ std::string const& file_prefix);
+ void doJSONObject(
+ Pipeline* p,
+ bool& first,
+ QPDF& pdf,
+ std::string const& key,
+ QPDFObjectHandle& obj);
void addOutlinesToJson(
std::vector<QPDFOutlineObjectHelper> outlines,
JSON& j,
@@ -638,6 +651,8 @@ class QPDFJob
int json_version;
std::set<std::string> json_keys;
std::set<std::string> json_objects;
+ qpdf_json_stream_data_e json_stream_data;
+ std::string json_stream_prefix;
bool test_json_schema;
bool check;
bool optimize_images;
diff --git a/include/qpdf/QPDFObjectHandle.hh b/include/qpdf/QPDFObjectHandle.hh
index eb16ad39..70c7cf54 100644
--- a/include/qpdf/QPDFObjectHandle.hh
+++ b/include/qpdf/QPDFObjectHandle.hh
@@ -1377,12 +1377,16 @@ class QPDFObjectHandle
// data_filename argument must be supplied. The value of
// data_filename is stored in the resulting json in the "datafile"
// key but is not otherwise use. The stream data itself (raw or
- // filtered depending on decode level), is written to the
- // pipeline via pipeStreamData().
+ // filtered depending on decode level), is written to the pipeline
+ // via pipeStreamData().
+ //
+ // NOTE: When json_data is qpdf_sj_inline, the QPDF object from
+ // which the stream originates must remain valid until after the
+ // JSON object is written.
QPDF_DLL
JSON getStreamJSON(
int json_version,
- qpdf_stream_data_json_e json_data,
+ qpdf_json_stream_data_e json_data,
qpdf_stream_decode_level_e decode_level,
Pipeline* p,
std::string const& data_filename);
diff --git a/include/qpdf/auto_job_c_main.hh b/include/qpdf/auto_job_c_main.hh
index af400e04..54efa1df 100644
--- a/include/qpdf/auto_job_c_main.hh
+++ b/include/qpdf/auto_job_c_main.hh
@@ -66,6 +66,7 @@ QPDF_DLL Config* removeAttachment(std::string const& parameter);
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* collate(std::string const& parameter);
QPDF_DLL Config* collate();
QPDF_DLL Config* splitPages(std::string const& parameter);
@@ -80,5 +81,6 @@ QPDF_DLL Config* objectStreams(std::string const& parameter);
QPDF_DLL Config* passwordMode(std::string const& parameter);
QPDF_DLL Config* removeUnreferencedResources(std::string const& parameter);
QPDF_DLL Config* streamData(std::string const& parameter);
+QPDF_DLL Config* jsonStreamData(std::string const& parameter);
QPDF_DLL Config* json(std::string const& parameter);
QPDF_DLL Config* json();