Some test text!

Loading...
Guides
Integrate

Integrate iOS PDF library with React Native

See here for the get started guide for using the PDFTron React Native SDK on Android.

This guide will help you integrate a free trial of the PDFTron SDK into your iOS applications using React Native. Your free trial includes unlimited trial usage and support from solution engineers.

Get the React Native source code

Prerequisites

  • PDFTron SDK >= 9.1.2
  • react-native >= 0.60.0
  • npm or yarn
  • TypeScript >= 3.4.1 (optional; see TypeScript)
No trial license key required.
The trial of PDFTron SDK works without a license key. A commercial license key is required for use in a production environment. Please fill out our licensing form if you do not have a valid license key.
Keep your commercial license key confidential.
License keys are uniquely generated. Please make sure that it is not publicly available (e.g. in your public GitHub).

Integrate

For simplicity the following guide is based on a boilerplate react native app for react-native init MyApp with git diff syntax for adding and removing lines from the boilerplate app.

  1. If using yarn, do: yarn global add react-native-cli

  2. First, follow the official getting started guide on setting up the React Native environment, setting up the iOS and Android environment, and creating a React Native project. The following steps will assume your app is created through react-native init MyApp. This guide also applies if you are using the TypeScript template.

  3. In MyApp folder, install react-native-pdftron by calling:

    yarn add github:PDFTron/pdftron-react-native
    yarn add @react-native-community/cli --dev
    yarn add @react-native-community/cli-platform-android --dev
    yarn add @react-native-community/cli-platform-ios --dev
    yarn install

    or

    npm install github:PDFTron/pdftron-react-native --save
    npm install @react-native-community/cli --save-dev
    npm install @react-native-community/cli-platform-android --save-dev
    npm install @react-native-community/cli-platform-ios --save-dev
  4. Open Podfile in the ios folder, add:

    target 'MyApp' do
        # ...
        pod 'PDFNet', podspec: 'https://www.pdftron.com/downloads/ios/cocoapods/pdfnet/latest.podspec'
        # ...
    end
  5. In the ios folder, run:

    pod install
  6. (Optional) If you need a close button icon, you will need to add the PNG resources to MyApp as well, i.e. ic_close_black_24px.

TypeScript

PDFTron React Native introduced support for TypeScript in version 3.0.0. This update mainly benefits those who already use TypeScript in their applications. It also provides certain benefits to all customers, including those who use JavaScript without TypeScript.

To get access to TypeScript support, simply update your PDFTron React Native dependency to version 3.0.0 or higher.

All Users

For non-TypeScript users, updating your PDFTron React Native dependency to version 3.0.0 or higher will not automatically install TypeScript itself, and you can continue to use the library as before (without TypeScript support). If you currently do not use TypeScript itself in your project and would like to, see Adding TypeScript to an Existing Project.

Regardless of whether you use TypeScript, the following benefits are available:

  • Proper API typings which can be used in tools such as IntelliSense. This offers insight into the data being passed without referring to the API documentation .
  • Greater type safety and reliability due to the migration of source files from JavaScript to TypeScript.
  • Updated Add an API guides to offer step-by-step, TypeScript-supported examples on accessing properties, methods, and events. Contributors should be aware that PRs must now be made to the dev branch (see Contributing).

If you have questions, head to the FAQ's React Native section .

TypeScript Users

If you are an existing TypeScript user, then the custom typings will be available to you simply by updating your PDFTron React Native dependency to version 3.0.0 or higher.

Note:

  • TypeScript version 3.4.1+ is recommended. Although compilation still works with lower versions, typings may degrade to any.
  • Due to the introduction of proper typings to PDFTron's APIs, your compiler may now give warnings or errors about your usage of these APIs. In most cases these will not prevent your app from running but it is advised that you address them to take full advantage of TypeScript. It is particularly important to address them if you use TypeScript to emit files and have enabled noEmitOnError in your tsconfig.json.

Next step

View a document

Get the answers you need: Support

PDFTron live tech update & run-through: Jan 20th at 11 am PT