public interface

PdfDocument

com.pspdfkit.api.PdfDocument

Class Overview

Represents an instance of a PDF document.

Summary

Public Methods
abstract DocumentEditor createDocumentEditor()
Creates a DocumentEditor with the current PdfDocument as the base to work from.
abstract void exportDocumentJson(WritableDataProvider writableDataProvider)
Exports Instant Document Json to a OutputStream For more information on the format, visit https://pspdfkit.com/guides/web/current/importing-exporting/instant-json/
abstract void exportXfdf(WritableDataProvider writableDataProvider, Set<Integer> annotationsToExport, Set<String> formFieldsToExport)
Exports XFDF to a OutputStream For the XFDF specification please see https://www.iso.org/obp/ui/#iso:std:iso:19444:-1:ed-1:v1:en
abstract AnnotationProvider getAnnotationProvider()
Returns AnnotationProvider object which handles annotations contained in this document.
abstract FormProvider getFormProvider()
Returns FormProvider object which handles forms contained in this document.
abstract PdfPage getPage(int pageIndex)
The PdfPage for the given index.
abstract long getPageCount()
The number of pages in the document.
abstract PdfProjection getPdfProjection()
Returns auxiliary projection class for mapping coordinate space between raw and normalized Pdf.
abstract void importDocumentJson(DataProvider dataProvider)
Import Instant Document Json from an DataProvider.
abstract void importXfdf(DataProvider dataProvider)
Import XFDF from an DataProvider.
abstract static PdfDocument open(DataProvider dataProvider)
Creates a PdfDocument instance from a DataProvider.
abstract void save(DocumentSaveOptions documentSaveOptions)
Save the current state back to the DataProvider used to open the document.
abstract void saveAs(WritableDataProvider dataProvider, DocumentSaveOptions documentSaveOptions)
Performs a full save of the document to a destination WritableDataProvider.

Public Methods

public abstract DocumentEditor createDocumentEditor ()

Creates a DocumentEditor with the current PdfDocument as the base to work from.

Returns

public abstract void exportDocumentJson (WritableDataProvider writableDataProvider)

Exports Instant Document Json to a OutputStream For more information on the format, visit https://pspdfkit.com/guides/web/current/importing-exporting/instant-json/

Parameters
writableDataProvider A `WritableDataProvider` to write the Document Json to.

public abstract void exportXfdf (WritableDataProvider writableDataProvider, Set<Integer> annotationsToExport, Set<String> formFieldsToExport)

Exports XFDF to a OutputStream For the XFDF specification please see https://www.iso.org/obp/ui/#iso:std:iso:19444:-1:ed-1:v1:en

Parameters
writableDataProvider A `WritableDataProvider` to write the XFDF to.
annotationsToExport A Nullable set of annotation id's to export.
formFieldsToExport A Nullable set of form field names to export.

public abstract AnnotationProvider getAnnotationProvider ()

Returns AnnotationProvider object which handles annotations contained in this document.

Returns
  • The annotation provider.

public abstract FormProvider getFormProvider ()

Returns FormProvider object which handles forms contained in this document.

public abstract PdfPage getPage (int pageIndex)

The PdfPage for the given index.

Parameters
pageIndex The index of the page to request based at 0.
Returns

public abstract long getPageCount ()

The number of pages in the document.

Returns
  • Number of pages.

public abstract PdfProjection getPdfProjection ()

Returns auxiliary projection class for mapping coordinate space between raw and normalized Pdf.

public abstract void importDocumentJson (DataProvider dataProvider)

Import Instant Document Json from an DataProvider. For more information on the format, visit https://pspdfkit.com/guides/web/current/importing-exporting/instant-json/

Parameters
dataProvider An DataProvider holding the Document Json.

public abstract void importXfdf (DataProvider dataProvider)

Import XFDF from an DataProvider. For the XFDF specification please see https://www.iso.org/obp/ui/#iso:std:iso:19444:-1:ed-1:v1:en

Parameters
dataProvider An DataProvider holding the XFDF.

public static abstract PdfDocument open (DataProvider dataProvider)

Creates a PdfDocument instance from a DataProvider.

Parameters
dataProvider The data holding a valid document.
Returns
  • An instance of PdfDocument representing the data given.

public abstract void save (DocumentSaveOptions documentSaveOptions)

Save the current state back to the DataProvider used to open the document.

Parameters
documentSaveOptions Options to customize the save. See DocumentSaveOptions.
Throws
IOException Throws if it is not possible to write to the open DataProvider.

public abstract void saveAs (WritableDataProvider dataProvider, DocumentSaveOptions documentSaveOptions)

Performs a full save of the document to a destination WritableDataProvider. getIncremental() and getForceSave() will be ignored as a full write is required to save to a new destination.

Parameters
dataProvider The destination to write the document to.
documentSaveOptions Options to customize the save. See DocumentSaveOptions.