PSPDFKit

PSPDFKit is a React Native Native Module implementation used to call iOS and Android methods directly.
Source:
Example
const PSPDFKit = NativeModules.PSPDFKit;

Members

(static) versionString :string

Used to get the current version of the underlying PSPDFKit SDK.
Type:
  • string
Source:
Example
const version = PSPDFKit.versionString

Methods

(static) dismiss() → {Promise.<boolean>}

Used to dismiss the PSPDFKitView.
Source:
Returns:
A promise returning true if the view was successfully dismissed, and false if not.
Type
Promise.<boolean>
Example
PSPDFKit.dismiss();

(static) present(documentPath, configuration) → {Promise.<boolean>}

Used to present a PDF document.
Parameters:
Name Type Description
documentPath string The path to the PDF document to be presented.
configuration PDFConfiguration Configuration object to customize the appearance and behavior of PSPDFKit. See https://pspdfkit.com/api/react-native/PDFConfiguration.html for available options.
Source:
Returns:
A promise returning true if the document was successfully presented, and false if not.
Type
Promise.<boolean>
Example
const fileName = 'document.pdf';
const exampleDocumentPath =
Platform.OS === 'ios' ? 'PDFs/' + fileName
: 'file:///android_asset/' + fileName;

const configuration: PDFConfiguration = {
   pageMode: PDFConfiguration.PageMode.AUTOMATIC,
   scrollDirection: PDFConfiguration.ScrollDirection.HORIZONTAL,
   enableAnnotationEditing: PDFConfiguration.BooleanType.TRUE,
   pageTransition: PDFConfiguration.PageTransition.SCROLL_CONTINUOUS
};

PSPDFKit.present(exampleDocumentPath, configuration);

(static) presentInstant(documentData, configuration) → {Promise.<boolean>}

Used to present an Instant PDF document for collaboration.
Parameters:
Name Type Description
documentData InstantDocumentData The Instant document data received entirely from the web response.
configuration PDFConfiguration Configuration object to customize the appearance and behavior of PSPDFKit. See https://pspdfkit.com/api/react-native/PDFConfiguration.html for available options. Also see InstantConfiguration for additional Instant configuration options.
Source:
See:
Returns:
A promise returning true if the document was successfully presented, and false if not.
Type
Promise.<boolean>
Example
// Data received from your backend service.
const serverResult = await fetch('your-backend-server-url');
const documentData = {
    jwt: serverResult.jwt,
    serverUrl: Constants.InstantServerURL
};
const configuration: PDFConfiguration = {
   enableInstantComments: PDFConfiguration.BooleanType.FALSE,
   listenToServerChanges: PDFConfiguration.BooleanType.TRUE,
   delay: 1,
   syncAnnotations: PDFConfiguration.BooleanType.TRUE,
};

PSPDFKit.presentInstant(documentData, configuration);

(static) processAnnotations(annotationChange, annotationType, sourceDocumentPath, processedDocumentPath) → {Promise.<boolean>}

Used to create a new document with processed annotations.
Parameters:
Name Type Description
annotationChange string Specifies how an annotation should be included in the resulting document. Available options are: flatten, remove, embed, and print.
annotationType string Specifies the annotation type that should be flattened. See https://pspdfkit.com/guides/web/json/schema/annotations/ for supported types. Use all to include all annotation types.
sourceDocumentPath string The source document to use as input.
processedDocumentPath string The path where the output document should be written to.
Source:
Returns:
A promise returning true if the document annotations were successfully flattened, and false if not.
Type
Promise.<boolean>
Example
const result = await PSPDFKit.processAnnotations(
                     'flatten',
                     'all',
                     sourceDocumentPath,
                     processedDocumentPath);

(static) setDelayForSyncingLocalChanges(delay)

Delay in seconds before kicking off automatic sync after local changes are made to the editableDocument’s annotations.
Parameters:
Name Type Description
delay number The delay in seconds.
Source:

(static) setLicenseKey(keyopt) → {Promise.<boolean>}

Used to set your PSPDFKit license key for the iOS platform only. PSPDFKit is commercial software. Each PSPDFKit license is bound to a specific app bundle ID. Visit https://customers.pspdfkit.com to get your demo or commercial license key.
Parameters:
Name Type Attributes Description
key string | null <optional>
Your PSPDFKit for React Native iOS license key.
Source:
Returns:
A promise returning true if the license key was set, and false if not.
Type
Promise.<boolean>
Example
PSPDFKit.setLicenseKey('YOUR_LICENSE_KEY');

(static) setLicenseKeys(androidKeyopt, iosKeyopt) → {Promise.<boolean>}

Used to set the your PSPDFKit license keys for both platforms. PSPDFKit is commercial software. Each PSPDFKit license is bound to a specific app bundle ID. Visit https://customers.pspdfkit.com to get your demo or commercial license key.
Parameters:
Name Type Attributes Description
androidKey string | null <optional>
Your PSPDFKit for React Native Android license key.
iosKey string | null <optional>
Your PSPDFKit for React Native iOS license key.
Source:
Returns:
A promise returning true if the license keys were set, and false if not.
Type
Promise.<boolean>
Example
PSPDFKit.setLicenseKeys('YOUR_ANDROID_LICENSE_KEY', 'YOUR_IOS_LICENSE_KEY');

(static) setListenToServerChanges(listenToServerChanges)

Automatically listen for and sync changes from the server.
Parameters:
Name Type Description
listenToServerChanges boolean true if server changes should be synced automatically, and false false otherwise.
Source:

(static) setPageIndex(pageIndex, animated) → {Promise.<boolean>}

Used to set the current page of the document. Starts at 0.
Parameters:
Name Type Description
pageIndex number The page to transition to.
animated boolean true if the transition should be animated, and false otherwise.
Source:
Returns:
A promise returning true if the page was successfully set, and false if not.
Type
Promise.<boolean>
Example
PSPDFKit.setPageIndex(3, false);