{"id":30309416,"url":"https://github.com/aprysesdk/pdftron-react-native","last_synced_at":"2025-08-17T13:43:49.297Z","repository":{"id":37602439,"uuid":"151463917","full_name":"ApryseSDK/pdftron-react-native","owner":"ApryseSDK","description":"A convenience wrapper for building react native apps with PDFTron mobile SDK.","archived":false,"fork":false,"pushed_at":"2025-07-08T22:18:07.000Z","size":11533,"stargazers_count":121,"open_issues_count":2,"forks_count":97,"subscribers_count":27,"default_branch":"master","last_synced_at":"2025-08-08T20:55:18.733Z","etag":null,"topics":["android","ios","pdf","pdftron","react-native"],"latest_commit_sha":null,"homepage":"https://www.pdftron.com/","language":"Objective-C","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ApryseSDK.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-10-03T18:53:28.000Z","updated_at":"2025-07-08T22:18:12.000Z","dependencies_parsed_at":"2024-01-16T07:33:56.307Z","dependency_job_id":"a9e277ff-a6d3-47f4-8e9e-b86418465b68","html_url":"https://github.com/ApryseSDK/pdftron-react-native","commit_stats":{"total_commits":735,"total_committers":32,"mean_commits":22.96875,"dds":0.6693877551020408,"last_synced_commit":"c929486a02937ec955b8dbd772ace90095bec619"},"previous_names":["aprysesdk/pdftron-react-native","pdftron/pdftron-react-native"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/ApryseSDK/pdftron-react-native","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ApryseSDK%2Fpdftron-react-native","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ApryseSDK%2Fpdftron-react-native/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ApryseSDK%2Fpdftron-react-native/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ApryseSDK%2Fpdftron-react-native/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ApryseSDK","download_url":"https://codeload.github.com/ApryseSDK/pdftron-react-native/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ApryseSDK%2Fpdftron-react-native/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270856590,"owners_count":24657693,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-17T02:00:09.016Z","response_time":129,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","ios","pdf","pdftron","react-native"],"created_at":"2025-08-17T13:43:48.364Z","updated_at":"2025-08-17T13:43:49.268Z","avatar_url":"https://github.com/ApryseSDK.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PDFTron React Native Wrapper\n\n- [API](API.md)\n- [Prerequisites](#prerequisites)\n- [Preview](#preview)\n- [Installation](#installation)\n- [Usage Github](#usage-github)\n- [Usage NPM](#usage-npm)\n- [TypeScript](#typescript)\n- [Contributing](#contributing)\n- [License](#license)\n\n## API\n\nAPIs are available on the [API page](API.md).\n\n## Prerequisites\n\n- No license key is required for trial. However, a valid commercial license key is required after trial.\n- npm or yarn\n- PDFTron SDK \u003e= 9.0.0\n- react-native \u003e= 0.60.0\n- TypeScript \u003e= 3.4.1 (optional; see [TypeScript](#typescript))\n\n## Preview\n\n|                                                             **Android**                                                             |                                                           **iOS**                                                           |\n| :---------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------: |\n| \u003cimg alt='demo-android' src='https://pdftron.s3.amazonaws.com/custom/websitefiles/android/react-native-ui-demo.gif' height=\"800\" /\u003e | \u003cimg alt='demo-ios' src='https://pdftron.s3.amazonaws.com/custom/websitefiles/ios/react-native-ui-demo.gif' height=\"800\" /\u003e |\n\n## Legacy UI\n\nVersion `2.0.2` is the last stable release for the legacy UI.\n\nThe release can be found here: https://github.com/ApryseSDK/pdftron-react-native/releases/tag/legacy-ui.\n\n## Pre-Java 17\n\nVersion `3.0.3-38` is the last stable release for pre-Java 17.\n\nThe release can be found here: https://github.com/ApryseSDK/pdftron-react-native/releases/tag/pre-java17.\n\n## Installation\n\n1. First, follow the official getting started guide on [setting up the React Native environment](https://reactnative.dev/docs/environment-setup), [setting up the iOS and Android environment](https://reactnative.dev/docs/environment-setup), and [creating a React Native project](https://reactnative.dev/docs/environment-setup). 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](https://reactnative.dev/docs/environment-setup#optional-using-a-specific-version-or-template).\n\n2. There are two ways to integrate the SDK:\n\n   - #### Through pdftron's github repo:\n\n     In `MyApp` folder, install `react-native-pdftron` by calling:\n\n     ```shell\n     yarn add github:ApryseSDK/pdftron-react-native\n     yarn install\n     ```\n\n     or\n\n     ```shell\n     npm install github:ApryseSDK/pdftron-react-native --save\n     npm install\n     ```\n\n   - #### Through pdftron's npm package:\n\n     In `MyApp` folder, install run the following commands:\n\n     ```shell\n     yarn add @pdftron/react-native-pdf\n     yarn install\n     ```\n\n     or\n\n     ```shell\n     npm install @pdftron/react-native-pdf\n     npm install\n     ```\n\n### Android\n\n1. Add the following in your `android/app/build.gradle` file:\n\n\t```diff\n\tdefaultConfig {\n\t    applicationId \"com.example.myapp\"\n\t    minSdkVersion rootProject.ext.minSdkVersion\n\t    targetSdkVersion rootProject.ext.targetSdkVersion\n\t    versionCode 1\n\t    versionName \"1.0.0\"\n\n\t+   resValue(\"string\", \"PDFTRON_LICENSE_KEY\", \"\\\"LICENSE_KEY_GOES_HERE\\\"\")\n\t}\n\t```\n   \n2. Add the following to your `android/app/src/main/AndroidManifest.xml` file:\n\n\t```diff\n\t\u003cmanifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n      package=\"com.example.myapp\"\u003e\n \n\t  \u003c!-- Required if you want to work with online documents --\u003e\n\t+ \u003cuses-permission android:name=\"android.permission.INTERNET\" /\u003e\n\t  \u003c!-- Required if you want to record audio annotations --\u003e\n\t+ \u003cuses-permission android:name=\"android.permission.RECORD_AUDIO\" /\u003e\n \n\t  \u003capplication\n\t    ...\n\t+   android:largeHeap=\"true\"\u003e\n\t\n\t    \u003c!-- Add license key in meta-data tag here. This should be inside the application tag. --\u003e\n\t+   \u003cmeta-data\n\t+     android:name=\"pdftron_license_key\"\n\t+     android:value=\"@string/PDFTRON_LICENSE_KEY\" /\u003e\n\t    ...\n      \u003cactivity\n\t      ...\n\t-     android:windowSoftInputMode=\"adjustResize\"\n\t+     android:windowSoftInputMode=\"adjustPan\"\u003e\n      \u003c/activity\u003e\n\t```\n\n3. Replace `App.js` (or `App.tsx`) with what is shown for [NPM](#Usage-NPM) or [GitHub](#Usage-Github)\n4. Finally in the root project directory, run `react-native run-android`.\n\n### iOS\n\n\u003e [!IMPORTANT]\n\u003e As of March 2025, use of the podspec distributed specifically for the PDFTron React Native wrapper (`https://pdftron.com/downloads/ios/react-native/latest.podspec`) is deprecated.\n\u003e \n\u003e **All new and existing users are recommended to use the standard [Apryse iOS SDK CocoaPods](https://docs.apryse.com/ios/guides/get-started/integration?tab=cocoapods) instead.**\n\u003e\n\u003e Please update your `Podfile` accordingly.\n\n1. Open `Podfile` in the `ios` folder, add the following line to the `target 'MyApp' do ... end` block:\n\n    ```\n    target 'MyApp' do\n        # ...\n        pod 'PDFNet', podspec: 'https://www.pdftron.com/downloads/ios/cocoapods/xcframeworks/pdfnet/latest.podspec'\n        # ...\n    end\n    ```\n\n2. In the `ios` folder, run `pod install`.\n3. Replace `App.js` (or `App.tsx`) with what is shown for [NPM](#Usage-NPM) or [GitHub](#Usage-Github)\n4. Finally in the root project directory, run `react-native run-ios`.\n5. (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`.\n\n## Usage-Github\n\nIf you installed through GitHub, replace `App.js` (or `App.tsx` if you are [using TypeScript](#typescript)) with the code below.\n\nIf you set your path variable to point to a local storage file,\nthen the `PermissionsAndroid` component is required to ensure that storage permission is properly granted.\n\nWithin this example there are several sections of commented out code that work together to\nhandle storage permissions.\n\nBelow the example are the types of file paths that are native to iOS or Android and accepted\nby the `DocumentView` component.\n\n```javascript\nimport React, { Component } from \"react\";\nimport {\n  Platform,\n  StyleSheet,\n  Text,\n  View,\n  PermissionsAndroid,\n  BackHandler,\n  NativeModules,\n  Alert,\n} from \"react-native\";\n\nimport { DocumentView, RNPdftron } from \"react-native-pdftron\";\n\ntype Props = {};\nexport default class App extends Component\u003cProps\u003e {\n  // If you are using TypeScript, use `constructor(props: Props) {`\n  // Otherwise, use:\n  constructor(props) {\n    super(props);\n\n    // Uses the platform to determine if storage permisions have been automatically granted.\n    // The result of this check is placed in the component's state.\n    // this.state = {\n    //   permissionGranted: Platform.OS === 'ios' ? true : false\n    // };\n\n    RNPdftron.initialize(\"Insert commercial license key here after purchase\");\n    RNPdftron.enableJavaScript(true);\n  }\n\n  // Uses the platform to determine if storage permissions need to be requested.\n  // componentDidMount() {\n  //   if (Platform.OS === 'android') {\n  //     this.requestStoragePermission();\n  //   }\n  // }\n\n  // Requests storage permissions for Android and updates the component's state using\n  // the result.\n  // async requestStoragePermission() {\n  //   try {\n  //     const granted = await PermissionsAndroid.request(\n  //       PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE\n  //     );\n  //     if (granted === PermissionsAndroid.RESULTS.GRANTED) {\n  //       this.setState({\n  //         permissionGranted: true\n  //       });\n  //       console.log(\"Storage permission granted\");\n  //     } else {\n  //       this.setState({\n  //         permissionGranted: false\n  //       });\n  //       console.log(\"Storage permission denied\");\n  //     }\n  //   } catch (err) {\n  //     console.warn(err);\n  //   }\n  // }\n\n  onLeadingNavButtonPressed = () =\u003e {\n    console.log(\"leading nav button pressed\");\n    if (Platform.OS === \"ios\") {\n      Alert.alert(\n        \"App\",\n        \"onLeadingNavButtonPressed\",\n        [{ text: \"OK\", onPress: () =\u003e console.log(\"OK Pressed\") }],\n        { cancelable: true }\n      );\n    } else {\n      BackHandler.exitApp();\n    }\n  };\n\n  render() {\n    // If the component's state indicates that storage permissions have not been granted,\n    // a view is loaded prompting users to grant these permissions.\n    // if (!this.state.permissionGranted) {\n    //   return (\n    //     \u003cView style={styles.container}\u003e\n    //       \u003cText\u003e\n    //         Storage permission required.\n    //       \u003c/Text\u003e\n    //     \u003c/View\u003e\n    //   )\n    // }\n\n    const path =\n      \"https://pdftron.s3.amazonaws.com/downloads/pl/PDFTRON_mobile_about.pdf\";\n\n    return (\n      \u003cDocumentView\n        document={path}\n        showLeadingNavButton={true}\n        leadingNavButtonIcon={\n          Platform.OS === \"ios\"\n            ? \"ic_close_black_24px.png\"\n            : \"ic_arrow_back_white_24dp\"\n        }\n        onLeadingNavButtonPressed={this.onLeadingNavButtonPressed}\n      /\u003e\n    );\n  }\n}\n\nconst styles = StyleSheet.create({\n  container: {\n    flex: 1,\n    justifyContent: \"center\",\n    alignItems: \"center\",\n    backgroundColor: \"#F5FCFF\",\n  },\n});\n```\n\n- (iOS) For app bundle file path:\n\n  ```javascript\n  document = \"sample\";\n  ```\n\n- (Android) For local storage file path:\n\n  ```javascript\n  document = \"file:///storage/emulated/0/Download/sample.pdf\";\n  ```\n\n- (Android) For raw resource path (include file extension):\n\n  ```javascript\n  document = \"android.resource://mypackagename/raw/sample.pdf\";\n  ```\n\n- (Android) For content Uri:\n\n  ```javascript\n  document = \"content://...\";\n  ```\n  \n## Usage-NPM\n\nIf you installed through NPM package, Replace `App.js` (or `App.tsx` if you are [using TypeScript](#typescript)) with the code below.\n\nIf you set your path variable to point to a local storage file,\nthen the `PermissionsAndroid` component is required to ensure that storage permission is properly granted.\n\nWithin this example there are several sections of commented out code that work together to\nhandle storage permissions.\n\nBelow the example are the types of file paths that are native to iOS or Android and accepted\nby the `DocumentView` component.\n\nif you are using the npm package use this instead\n\n```javascript\nimport React, { Component } from \"react\";\nimport {\n  Platform,\n  StyleSheet,\n  Text,\n  View,\n  PermissionsAndroid,\n  BackHandler,\n  NativeModules,\n  Alert,\n} from \"react-native\";\n\nimport { DocumentView, RNPdftron } from \"@pdftron/react-native-pdf\";\n\ntype Props = {};\nexport default class App extends Component\u003cProps\u003e {\n  // If you are using TypeScript, use `constructor(props: Props) {`\n  // Otherwise, use:\n  constructor(props) {\n    super(props);\n\n    // Uses the platform to determine if storage permisions have been automatically granted.\n    // The result of this check is placed in the component's state.\n    // this.state = {\n    //   permissionGranted: Platform.OS === 'ios' ? true : false\n    // };\n\n    RNPdftron.initialize(\"Insert commercial license key here after purchase\");\n    RNPdftron.enableJavaScript(true);\n  }\n\n  // Uses the platform to determine if storage permissions need to be requested.\n  // componentDidMount() {\n  //   if (Platform.OS === 'android') {\n  //     this.requestStoragePermission();\n  //   }\n  // }\n\n  // Requests storage permissions for Android and updates the component's state using\n  // the result.\n  // async requestStoragePermission() {\n  //   try {\n  //     const granted = await PermissionsAndroid.request(\n  //       PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE\n  //     );\n  //     if (granted === PermissionsAndroid.RESULTS.GRANTED) {\n  //       this.setState({\n  //         permissionGranted: true\n  //       });\n  //       console.log(\"Storage permission granted\");\n  //     } else {\n  //       this.setState({\n  //         permissionGranted: false\n  //       });\n  //       console.log(\"Storage permission denied\");\n  //     }\n  //   } catch (err) {\n  //     console.warn(err);\n  //   }\n  // }\n\n  onLeadingNavButtonPressed = () =\u003e {\n    console.log(\"leading nav button pressed\");\n    if (Platform.OS === \"ios\") {\n      Alert.alert(\n        \"App\",\n        \"onLeadingNavButtonPressed\",\n        [{ text: \"OK\", onPress: () =\u003e console.log(\"OK Pressed\") }],\n        { cancelable: true }\n      );\n    } else {\n      BackHandler.exitApp();\n    }\n  };\n\n  render() {\n    // If the component's state indicates that storage permissions have not been granted,\n    // a view is loaded prompting users to grant these permissions.\n    // if (!this.state.permissionGranted) {\n    //   return (\n    //     \u003cView style={styles.container}\u003e\n    //       \u003cText\u003e\n    //         Storage permission required.\n    //       \u003c/Text\u003e\n    //     \u003c/View\u003e\n    //   )\n    // }\n\n    const path =\n      \"https://pdftron.s3.amazonaws.com/downloads/pl/PDFTRON_mobile_about.pdf\";\n\n    return (\n      \u003cDocumentView\n        document={path}\n        showLeadingNavButton={true}\n        leadingNavButtonIcon={\n          Platform.OS === \"ios\"\n            ? \"ic_close_black_24px.png\"\n            : \"ic_arrow_back_white_24dp\"\n        }\n        onLeadingNavButtonPressed={this.onLeadingNavButtonPressed}\n      /\u003e\n    );\n  }\n}\n\nconst styles = StyleSheet.create({\n  container: {\n    flex: 1,\n    justifyContent: \"center\",\n    alignItems: \"center\",\n    backgroundColor: \"#F5FCFF\",\n  },\n});\n```\n\n- (iOS) For app bundle file path:\n\n  ```javascript\n  document = \"sample\";\n  ```\n\n- (Android) For local storage file path:\n\n  ```javascript\n  document = \"file:///storage/emulated/0/Download/sample.pdf\";\n  ```\n\n- (Android) For raw resource path (include file extension):\n\n  ```javascript\n  document = \"android.resource://mypackagename/raw/sample.pdf\";\n  ```\n\n- (Android) For content Uri:\n\n  ```javascript\n  document = \"content://...\";\n  ```\n## TypeScript\n\nPDFTron 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.\n\nTo get access to TypeScript support, simply update your PDFTron React Native dependency to version 3.0.0 or higher.\n\n### All Users\n\nFor 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](https://reactnative.dev/docs/typescript#adding-typescript-to-an-existing-project).\n\nRegardless of whether you use TypeScript, the following benefits are available:\n\n- Proper API typings which can be used in tools such as [IntelliSense](https://code.visualstudio.com/docs/editor/intellisense). This offers insight into the data being passed without referring to the [API documentation](API.md).\n- Greater type safety and reliability due to the migration of source files from JavaScript to TypeScript.\n- Updated Add an API guides for [Android](https://www.pdftron.com/documentation/android/get-started/react-native/add-an-api/) and [iOS](https://www.pdftron.com/documentation/ios/get-started/react-native/add-an-api) 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](./CONTRIBUTING.md)).\n\nIf you have questions, head to the FAQ's Integration section for [Android](https://www.pdftron.com/documentation/android/faq) and [iOS](https://www.pdftron.com/documentation/ios/faq/).\n\n### TypeScript Users\n\nIf 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.\n\nNote:\n\n- TypeScript version 3.4.1+ is recommended. Although compilation still works with lower versions, typings may degrade to `any`.\n- 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`.\n\n## Contributing\n\nSee [Contributing](./CONTRIBUTING.md)\n\n## License\n\nSee [License](./LICENSE)\n![](https://onepixel.pdftron.com/pdftron-react-native)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faprysesdk%2Fpdftron-react-native","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faprysesdk%2Fpdftron-react-native","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faprysesdk%2Fpdftron-react-native/lists"}