exportDocumentJsonAsync

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

Asynchronously 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 will start upon subscribing to the Completable returned by this method. The returned completable does not operate on any particular scheduler. If you want to run the serialization process on a background thread, consider calling subscribeOn on the completable before subscribing.

The returned completable will emit a DocumentJsonFormatterException when encountering an unexpected error while exporting the JSON.

Exporting of compound documents 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.

Return

A Completable that will start the JSON export once its subscribe method is called.

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 exportDocumentJsonAsync(@NonNull document: PdfDocument, @NonNull outputStream: OutputStream, @NonNull instantJsonVersion: InstantJsonVersion): Completable

See docs for exportDocumentJsonAsync 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