Some test text!

Add an APIkeyboard_arrow_down

Add an API for React Native


The PDFTron iOS React Native API includes all of the most used functions and methods for viewing, annotating and saving PDF documents. However, it is possible your app may need access to APIs that are available as part of the native API, but are not directly available to React Native.

This guide provides an example of how to add a "pageChangeOnTap" prop to the React Native interface, which determines whether page will turn left or right when tapping corresponding edges. You can follow the same pattern to add new props that your React Native app may need. The new props could be simple ones, which expose one piece of functionality, or custom ones, that expose a series of native commands under the hood.

Prior to following this guide, we highly recommend you to go through the official guide here: Native UI Components to have a better understanding of the system.

Example: Adding the "pageChangeOnTap" prop

1. Fork and clone PDFTron's React Native Repo

The source is hosted on GitHub here:

Fork the project and clone a copy of the repository to your disk.

2. Update the DocumentView.js interface file

The DocumentView.js interface file lists all of the React Native props on the DocumentView component.

Add the prop declaration:

static propTypes = {
  pageChangeOnTap: PropTypes.bool,

3. Define a ReactProp matches the JS declaration

Open file ios/RNTPTDocumentViewManager.m.

Add the method key that matches the JS declaration:

    if (json) {
        view.pageChangeOnTap = [RCTConvert BOOL:json];

4. Implement the new method

Open the ios/RNTPTDocumentView.h interface file and add a new property to the RNTPTDocumentView class:

@interface RNTPTDocumentView


@property (nonatomic, assign) BOOL pageChangeOnTap;



Open the ios/RNTPTDocumentView.m implementation file to add the property implementation:

- (void)setPageChangeOnTap:(BOOL)pageChangeOnTap
    _pageChangeOnTap = pageChangeOnTap;
    if (self.documentViewController) {
        [self applyViewerSettings];

and add the following to the applyViewerSettings method:

- (void)applyViewerSettings

    // Page change on tap.
    self.documentViewController.changesPageOnTap = self.pageChangeOnTap;


The actual implementation will depend on the actual functionality.

5. Push the code and integrate the updated source

Now npm install your forked version to your application.

The new prop is now ready to use.

6. Access the new functionality

The app can now access the new API as follows:


7. All done!

If you're only developing for iOS, then you're all done!

If you're also deploying on Android, you'll need to repeat steps 3 to 5 for Android.

If you're developing for both iOS and Android, please consider submitting a PR, as upstreaming the change will simplify your developing and make the props available for other PDFTron customers.

Get the answers you need: Support


Free Trial

Get unlimited trial usage of PDFTron SDK to bring accurate, reliable, and fast document processing capabilities to any application or workflow.

Select a platform to get started with your free trial.

Unlimited usage. No email address required.