exportDocumentJson

open fun exportDocumentJson(@NonNull document: PdfDocument, @NonNull outputStream: OutputStream)

Exports all (unsaved) changes to annotations, and form elements made since opening the given document into a JSON string. This JSON string contains a pdfId and can only be imported on the exact same document again. Trying to import it in a different document will throw a DocumentJsonFormatterException. One possible use case for document JSON is syncing document changes without having to send the entire PDF.

The generated JSON is written to outputStream. Serialization is performed on the current thread. Avoid calling this method on the main thread and consider using exportDocumentJsonAsync instead to avoid that your application becomes unresponsive.

The method will throw a DocumentJsonFormatterException when encountering an unexpected error while exporting the JSON.

Exporting of compound documents changes is not supported. This method will throw an exception if called with a compound document (i.e. a document having more than one document source).

Uses the latest Instant JSON protocol version. See exportDocumentJson to specify the version for compatibility with older clients.

Parameters

document

The PdfDocument to serialize. This must not be a compound document.

outputStream

The OutputStream to which the JSON should be written.

See also


open fun exportDocumentJson(@NonNull document: PdfDocument, @NonNull outputStream: OutputStream, @NonNull instantJsonVersion: InstantJsonVersion)

See docs for exportDocumentJson This method also allows you to specify which Instant JSON format version to export. The above method uses the latest version. For compatibility with older clients who have not upgraded their PSPDFKit SDK, you can pass a specific version here.

Parameters

document

The PdfDocument to serialize. This must not be a compound document.

outputStream

The OutputStream to which the JSON should be written.

instantJsonVersion

The InstantJsonVersion format version for the output JSON.

See also