diff options
author | Jay Berkenbilt <ejb@ql.org> | 2018-12-17 23:40:29 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2018-12-22 00:34:56 +0100 |
commit | 30a0c070e41212172f5516936594ec0f6e72ac70 (patch) | |
tree | 86ee45692ce7f54e3298d84f20a86fd482afbbaa /include | |
parent | 651179b5da0777f861e427f96fd8560bf1516ae5 (diff) | |
download | qpdf-30a0c070e41212172f5516936594ec0f6e72ac70.tar.zst |
Add QPDFObjectHandle::getJSON()
Diffstat (limited to 'include')
-rw-r--r-- | include/qpdf/QPDFObject.hh | 2 | ||||
-rw-r--r-- | include/qpdf/QPDFObjectHandle.hh | 19 |
2 files changed, 21 insertions, 0 deletions
diff --git a/include/qpdf/QPDFObject.hh b/include/qpdf/QPDFObject.hh index 0bc4a03c..37dfeecf 100644 --- a/include/qpdf/QPDFObject.hh +++ b/include/qpdf/QPDFObject.hh @@ -24,6 +24,7 @@ #include <qpdf/DLL.h> #include <qpdf/PointerHolder.hh> +#include <qpdf/JSON.hh> #include <string> @@ -62,6 +63,7 @@ class QPDFObject virtual ~QPDFObject() {} virtual std::string unparse() = 0; + virtual JSON getJSON() = 0; // Return a unique type code for the object virtual object_type_e getTypeCode() const = 0; diff --git a/include/qpdf/QPDFObjectHandle.hh b/include/qpdf/QPDFObjectHandle.hh index 88f071d2..9cc67686 100644 --- a/include/qpdf/QPDFObjectHandle.hh +++ b/include/qpdf/QPDFObjectHandle.hh @@ -733,6 +733,25 @@ class QPDFObjectHandle QPDF_DLL std::string unparseBinary(); + // Return encoded as JSON. For most object types, there is an + // obvious mapping. The JSON is generated as follows: + // * Names are encoded as strings representing the normalized value of + // getName() + // * Indirect references are encoded as strings containing "obj gen R" + // * Strings are encoded as UTF-8 strings with unrepresentable binary + // characters encoded as \uHHHH + // * Encoding streams just encodes the stream's dictionary; the stream + // data is not represented + // * 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". + // 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 + // recursive. + QPDF_DLL + JSON getJSON(bool dereference_indirect = false); + // Legacy helper methods for commonly performed operations on // pages. Newer code should use QPDFPageObjectHelper instead. The // specification and behavior of these methods are the same as the |