{"id":4035,"url":"https://github.com/cnjon/react-native-pdf-view","last_synced_at":"2025-08-04T00:31:04.403Z","repository":{"id":52798434,"uuid":"48735825","full_name":"cnjon/react-native-pdf-view","owner":"cnjon","description":"React Native PDF View","archived":false,"fork":false,"pushed_at":"2021-04-19T05:38:46.000Z","size":6289,"stargazers_count":404,"open_issues_count":59,"forks_count":167,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-11-30T02:44:58.227Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cnjon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-29T08:01:33.000Z","updated_at":"2024-11-05T22:54:36.000Z","dependencies_parsed_at":"2022-09-17T03:01:10.470Z","dependency_job_id":null,"html_url":"https://github.com/cnjon/react-native-pdf-view","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnjon%2Freact-native-pdf-view","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnjon%2Freact-native-pdf-view/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnjon%2Freact-native-pdf-view/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnjon%2Freact-native-pdf-view/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cnjon","download_url":"https://codeload.github.com/cnjon/react-native-pdf-view/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228576892,"owners_count":17939645,"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","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":[],"created_at":"2024-01-05T20:16:59.130Z","updated_at":"2024-12-07T07:30:57.692Z","avatar_url":"https://github.com/cnjon.png","language":"Objective-C","funding_links":[],"categories":["Components","\u003ca name=\"Image-\u0026-Audio-\u0026-Video-\u0026-Docs:-Native-Modules\"\u003eImage, Audio, Video \u0026 Docs: Native Modules\u003c/a\u003e","Others"],"sub_categories":["UI"],"readme":"# react-native-pdf-view\nReact Native PDF View (cross-platform support)\n\n### Breaking changes\n\n* React native 0.40 moved iOS headers, thus all iOS react import statements has been changed. Use version 0.4.* for react native \u003e=0.40. For earlier version see below breaking change.\n\n* React native 0.19 changed the ReactProps class which led to problems with updating native view properties (see https://github.com/facebook/react-native/issues/5649). These errors are corrected in react-native-pdf-view version 0.2.0. Use version 0.2.* for react native \u003e=0.19 and for earlier react native versions use version 0.1.3.\n\n### Installation\n```bash\nnpm i react-native-pdf-view --save\n\nreact-native link react-native-pdf-view\n```\n* In `android/setting.gradle`\n\n```gradle\n...\ninclude ':PDFView'\nproject(':PDFView').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-pdf-view/android')\n```\n\n* In `android/app/build.gradle`\n\n```gradle\n...\ndependencies {\n    ...\n    compile project(':PDFView')\n}\n```\n\n* register module (in MainActivity.java)\n\nOn newer versions of React Native (0.18+):\n```java\nimport com.keyee.pdfview.PDFView;  // \u003c--- import\n\npublic class MainActivity extends ReactActivity {\n  ......\n    @Override\n    protected List\u003cReactPackage\u003e getPackages() {\n      return Arrays.\u003cReactPackage\u003easList(\n        new PDFView(), // \u003c------ add here\n        new MainReactPackage());\n    }\n}\n```\n\nOn older versions of React Native:\n```java\nimport com.keyee.pdfview.PDFView;  // \u003c--- import\n\npublic class MainActivity extends Activity implements DefaultHardwareBackBtnHandler {\n  ......\n\n  @Override\n  protected void onCreate(Bundle savedInstanceState) {\n    super.onCreate(savedInstanceState);\n    mReactRootView = new ReactRootView(this);\n\n    mReactInstanceManager = ReactInstanceManager.builder()\n      .setApplication(getApplication())\n      .setBundleAssetName(\"index.android.bundle\")\n      .setJSMainModuleName(\"index.android\")\n      .addPackage(new MainReactPackage())\n      .addPackage(new PDFView())              // \u003c------ add here\n      .setUseDeveloperSupport(BuildConfig.DEBUG)\n      .setInitialLifecycleState(LifecycleState.RESUMED)\n      .build();\n\n    mReactRootView.startReactApplication(mReactInstanceManager, \"ExampleRN\", null);\n\n    setContentView(mReactRootView);\n  }\n\n  ......\n\n}\n```\n\n### Usage\n\nFirst, require it from your app's JavaScript files with:\n```bash\nimport PDFView from 'react-native-pdf-view';\n```\n\n\n### Example\n\n```js\n'use strict';\n\nimport React,{\n    Component\n} from 'react';\n\nimport {\n    StyleSheet,\n    View\n} from 'react-native';\n\nimport PDFView from 'react-native-pdf-view';\n\nexport default class PDF extends Component {\n    constructor(props) {\n        super(props);\n    }\n\n    render(){\n      \u003cPDFView ref={(pdf)=\u003e{this.pdfView = pdf;}}\n                         src={\"sdcard/pdffile.pdf\"}\n                         onLoadComplete = {(pageCount)=\u003e{\n                            this.pdfView.setNativeProps({\n                                zoom: 1.5\n                            });\n                         }}\n                         style={styles.pdf}/\u003e\n    }\n}\nvar styles = StyleSheet.create({\n    pdf: {\n        flex:1\n    }\n});\n```\n\n\n### Configuration\n\n| Property      | Type        \t| Default \t\t \t\t\t\t| Description | iOS | Android |\n| ------------- |:-------------:|:------------:\t\t\t\t| ----------- | --- | ------- |\n| path        | string \t\t\t| null \t\t\t \t\t\t\t| pdf absolute path| ✔   | ✔ |\n| src        | string \t\t\t| null \t\t\t \t\t\t\t| pdf absolute path(`Deprecated`) | ✔   | ✔ |\n| asset        | string \t\t\t| null \t\t\t \t\t\t\t| the name of a PDF file in the asset folder |   | ✔ |\n| pageNumber    \t\t  | number  \t    |\t1 \t\t \t\t\t\t| page index | ✔   | ✔ |\n| zoom \t\t  | number  \t    |\t1.0 \t| zoom scale | ✔   | ✔ |\n| onLoadComplete \t\t\t| function     \t  | null\t \t\t\t| page load complete,return page count | ✔   | ✔ |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcnjon%2Freact-native-pdf-view","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcnjon%2Freact-native-pdf-view","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcnjon%2Freact-native-pdf-view/lists"}