ExportDocumentJSON

Document exchange

Description

Serialises the complete document object graph to a JSON file in qPDF-style structure

Syntax

Delphi

Function ExportDocumentJSON(Const FileName: WideString; Options: Integer): Integer;

Parameters

FileNameDestination path for the JSON file; must not be empty
OptionsBit mask: 1 omits base64 stream payloads and keeps dictionaries only, 2 appends the trailer dictionary; zero writes stream payloads and no trailer entry

Return values

0No document is loaded or the file could not be written
1The JSON file was written

Remarks

Options is a bit mask: 1 omits base64 stream payloads and keeps dictionaries only, 2 appends the trailer dictionary. The output uses the qPDF JSON v2 layout: a top-level qpdf array with a metadata element and an objects object keyed by obj:N G R entries. Stream objects carry a stream node with a dict object and a base64 data string

Names, strings and indirect references are all written as plain JSON strings: a name without its leading slash, a string as its bytes, a reference as N G R. The JSON alone therefore does not say which of the three a given string was. The layout is specific to this library and is meant for inspection and comparison; despite the name of the top-level key, the file is not interchangeable with JSON written or read by other tools, and it cannot be loaded back into a document

The file contains valid UTF-8 JSON. PDF strings and names preserve raw byte values using JSON Unicode escapes for control and high-bit bytes. Numbers retain their decimal precision, and pdfversion reports the loaded PDF version

Example

PDF.ExportDocumentJSON("dump.json", 2);

See also

AuditDocumentSpace, AnalyseFile