aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-05-07 17:12:15 +0200
committerJay Berkenbilt <ejb@ql.org>2022-05-08 19:45:20 +0200
commit1bc8abfdd3eb9b5a6af5d274c85cd1708bdb9e0c (patch)
treef60184566462e0c5df996ca54bc8f6ba3f3a356f /include
parent3246923cf2189554f7c348ebf51c9774c09deec8 (diff)
downloadqpdf-1bc8abfdd3eb9b5a6af5d274c85cd1708bdb9e0c.tar.zst
Implement JSON v2 for Stream
Not fully exercised in this commit
Diffstat (limited to 'include')
-rw-r--r--include/qpdf/Constants.h6
-rw-r--r--include/qpdf/QPDFObjectHandle.hh43
2 files changed, 44 insertions, 5 deletions
diff --git a/include/qpdf/Constants.h b/include/qpdf/Constants.h
index c50a9563..babf215c 100644
--- a/include/qpdf/Constants.h
+++ b/include/qpdf/Constants.h
@@ -99,6 +99,12 @@ enum qpdf_stream_decode_level_e {
qpdf_dl_specialized, /* also decode other non-lossy filters */
qpdf_dl_all /* also decode lossy filters */
};
+/* For JSON encoding */
+enum qpdf_stream_data_json_e {
+ qpdf_sj_none = 0,
+ qpdf_sj_inline,
+ qpdf_sj_file,
+};
/* R3 Encryption Parameters */
diff --git a/include/qpdf/QPDFObjectHandle.hh b/include/qpdf/QPDFObjectHandle.hh
index 82f4e365..eb16ad39 100644
--- a/include/qpdf/QPDFObjectHandle.hh
+++ b/include/qpdf/QPDFObjectHandle.hh
@@ -1339,8 +1339,8 @@ class QPDFObjectHandle
// unambiguous. The getStreamJSON() call can be used to add
// encoding of the stream's data.
// * Object types that are only valid in content streams (inline
- // image, operator) as well as "reserved" objects are not
- // representable and will be serialized as "null".
+ // image, operator) are serialized as "null". Attempting to
+ // serialize a "reserved" object is an error.
// If dereference_indirect is true and this is an indirect object,
// show the actual contents of the object. The effect of
// dereference_indirect applies only to this object. It is not
@@ -1350,9 +1350,42 @@ class QPDFObjectHandle
// Deprecated version uses v1 for backward compatibility.
// ABI: remove for qpdf 12
- [[deprecated("Use getJSON(int version)")]]
- QPDF_DLL
- JSON getJSON(bool dereference_indirect = false);
+ [[deprecated("Use getJSON(int version)")]] QPDF_DLL JSON
+ getJSON(bool dereference_indirect = false);
+
+ // This method can be called on a stream to get a more extended
+ // JSON representation of the stream that includes the stream's
+ // data. The JSON object returned is always a dictionary whose
+ // "dict" key is an encoding of the stream's dictionary. The
+ // representation of the data is determined by the json_data
+ // field.
+ //
+ // The json_data field may have the value qpdf_sj_none,
+ // qpdf_sj_inline, or qpdf_sj_file.
+ //
+ // If json_data is qpdf_sj_none, stream data is not represented.
+ //
+ // If json_data is qpdf_sj_inline or qpdf_sj_file, then stream
+ // data is filtered or not based on the value of decode_level,
+ // which has the same meaning as with pipeStreamData.
+ //
+ // If json_data is qpdf_sj_inline, the base64-encoded stream data
+ // is included in the "data" field of the dictionary that is
+ // returned.
+ //
+ // If json_data is qpdf_sj_file, then the Pipeline ("p") and
+ // 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().
+ QPDF_DLL
+ JSON getStreamJSON(
+ int json_version,
+ qpdf_stream_data_json_e json_data,
+ qpdf_stream_decode_level_e decode_level,
+ Pipeline* p,
+ std::string const& data_filename);
// Legacy helper methods for commonly performed operations on
// pages. Newer code should use QPDFPageObjectHelper instead. The