DocumentJsonFormatter

Exports and imports changes made to annotations and form fields of a PdfDocument into a JSON string. JSON strings created and read by this class are also used by PSPDFKit Instant.

The JSON generated by this class represents a set of all annotation, and form field changes to the original document (i.e. the document in the state in which it was loaded). It comprises all added annotations, changes to existing annotations, deleted annotations, and also values entered into form fields. More info on the JSON format is available in our online guides.

One possible use case for using this is syncing changes made to the document without having to transmit the entire PDF document.

Functions

Link copied to clipboard
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.
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.
Link copied to clipboard
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.
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.
Link copied to clipboard
open fun importDocumentJson(@NonNull document: PdfDocument, @NonNull dataProvider: DataProvider)
Imports a document JSON and applies its changes to the given document.
Link copied to clipboard
open fun importDocumentJsonAsync(@NonNull document: PdfDocument, @NonNull dataProvider: DataProvider): Completable
Asynchronously imports a document JSON and applies its changes to the given document.