{"id":24543866,"url":"https://github.com/douglasjunior/react-native-pdf-renderer","last_synced_at":"2025-04-05T10:10:51.208Z","repository":{"id":131839202,"uuid":"611701429","full_name":"douglasjunior/react-native-pdf-renderer","owner":"douglasjunior","description":"⚛ A zoomable, blazing fast, zero dependencies, pure native, typed PDF Renderer for Android and iOS.","archived":false,"fork":false,"pushed_at":"2024-09-26T12:09:20.000Z","size":68718,"stargazers_count":131,"open_issues_count":3,"forks_count":3,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-09-26T12:10:47.700Z","etag":null,"topics":["android","ios","pdf","pdfkit","pdfrenderer","react-native"],"latest_commit_sha":null,"homepage":"","language":"Java","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/douglasjunior.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"douglasjunior","patreon":"douglasjunior","custom":"paypal.me/douglasnassif"}},"created_at":"2023-03-09T11:19:24.000Z","updated_at":"2024-09-26T12:09:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"c001e2e7-08db-47ee-94de-150fa710b5c4","html_url":"https://github.com/douglasjunior/react-native-pdf-renderer","commit_stats":{"total_commits":60,"total_committers":4,"mean_commits":15.0,"dds":"0.33333333333333337","last_synced_commit":"0ae49ce77b2575ac4c71e688ed49d2865773bfa2"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/douglasjunior%2Freact-native-pdf-renderer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/douglasjunior%2Freact-native-pdf-renderer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/douglasjunior%2Freact-native-pdf-renderer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/douglasjunior%2Freact-native-pdf-renderer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/douglasjunior","download_url":"https://codeload.github.com/douglasjunior/react-native-pdf-renderer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247318745,"owners_count":20919484,"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":["android","ios","pdf","pdfkit","pdfrenderer","react-native"],"created_at":"2025-01-22T20:15:20.527Z","updated_at":"2025-04-05T10:10:51.185Z","avatar_url":"https://github.com/douglasjunior.png","language":"Java","funding_links":["https://github.com/sponsors/douglasjunior","https://patreon.com/douglasjunior","paypal.me/douglasnassif","https://www.patreon.com/douglasjunior","https://paypal.me/douglasnassif"],"categories":[],"sub_categories":[],"readme":"# React-Native Pdf Renderer\n\n[![License MIT](https://img.shields.io/badge/licence-MIT-blue.svg)](https://github.com/douglasjunior/react-native-pdf-renderer/blob/main/LICENSE)\n[![npm version](https://img.shields.io/npm/v/react-native-pdf-renderer.svg)](https://www.npmjs.com/package/react-native-pdf-renderer?activeTab=versions)\n[![npm downloads](https://img.shields.io/npm/dt/react-native-pdf-renderer.svg)](https://www.npmjs.com/package/react-native-pdf-renderer)\n\n⚛ A zoomable, blazing fast, zero dependencies, pure native, typed PDF Renderer for Android and iOS.\n\nIt uses [PdfRenderer](https://developer.android.com/reference/android/graphics/pdf/PdfRenderer) for Android and [PdfKit](https://developer.apple.com/documentation/pdfkit) for iOS.\n\n|Android|iOS|\n|-|-|\n|\u003cimg src=\"https://github.com/douglasjunior/react-native-pdf-renderer/raw/main/screenshots/android.gif\" width=\"240\"/\u003e|\u003cimg src=\"https://github.com/douglasjunior/react-native-pdf-renderer/raw/main/screenshots/ios.gif\" width=\"240\"/\u003e\n\n## Why another PDF renderer?\n\nThe main reason why I create this library is to avoid using third-party native dependencies, like `com.github.TalbotGooday:AndroidPdfViewer`, `com.github.mhiew:android-pdf-viewer`, `react-native-blob-util` or even `react-native-webview`. \n\nBut why?\n\nEvery React Native developer knows (or will discover soon) [the pain of updating the React Native ecosystem](https://x.com/flexbox_/status/1806786055057674337) when a new version of Android or iOS comes out, so here we want to avoid this pain as much as possible.\n\n## Requirements\n\n- React Native \u003e= 0.60.0\n- iOS \u003e= 11.0\n- Android \u003e= API 19\n\n## Install\n\nInstall dependency package\n```bash\nyarn add react-native-pdf-renderer\n```\nOr\n```bash\nnpm i -S react-native-pdf-renderer\n```\n\nGo to the folder **your-project/ios** and run `pod install`, and you're done. \n\n### Android specific (optional)\n\nCustomize the [`androidx.recyclerview:recyclerview`](https://developer.android.com/jetpack/androidx/releases/recyclerview) version by setting `ext` in your `android/build.gradle` file.\n\nExample:\n\n```gradle\nbuildscript {\n  ext {\n    recyclerviewVersion = \"1.2.1\"\n  }\n  ...\n}\n```\n\n## Basic usage\n\nThere is only one component that you need to use to render the PDF file.\n\n```jsx\nimport PdfRendererView from 'react-native-pdf-renderer';\n\nconst App = () =\u003e {\n  return (\n    \u003cSafeAreaView style={{flex: 1}}\u003e\n      \u003cPdfRendererView\n        style={{backgroundColor: 'red'}}\n        source=\"file:///path/to/local/file.pdf\"\n        distanceBetweenPages={16}\n        maxZoom={5}\n        onPageChange={(current, total) =\u003e {\n          console.log(current, total);\n        }}\n      /\u003e\n    \u003c/SafeAreaView\u003e\n  );\n}\n\nexport default App;\n```\n\nThe `source` prop must point to a file stored inside the device memory. \n\nIf the file is online, you can use some third-party library like `expo-file-system`, `rn-fetch-blob`, or `react-native-blob-util` to download and save it locally.\n\nFor more details, see the [Sample Project](https://github.com/douglasjunior/react-native-pdf-renderer/blob/main/Sample/App.tsx).\n\n## PdfRendererView props\n\n|Name|Type|Default|Description|\n|-|-|-|-|\n|source|`string`||Path to a file stored on the device.|\n|distanceBetweenPages|`number`|`16`|Distance in `DPI` between pages.|\n|maxZoom|`number`|`5`|Max zoom scale.|\n|maxPageResolution|`number`|`2048`|(Android only) Max page resolution (width/height) in pixels when zooming. Defined to prevent Android crash when zooming too much: https://github.com/douglasjunior/react-native-pdf-renderer/issues/26 . |\n|singlePage|`boolean`|`false`|(Experimental) Renders only the first page without scroll. (useful for display thumbnail)|\n|onPageChange|`(current: number, total: number) =\u003e void`||Invoked on pages scroll.|\n|style|`StyleProp\u003cViewStyle\u003e`||Styles to be applied to the native [view](https://reactnative.dev/docs/view-style-props).|\n\n## Limitations\n\n### Page interactions\n\nBecause Android renders the PDF page as a full image, it does not support text selection, accessibility, or handling links. \n\nIf any of these features are important for your product, we recommend adding a button to open the PDF in an external PDF viewer.\n\n### Size measuring\n\nThe `PdfRendererView` is `flex: 1` by default, so you need to make sure that your parents `View`s are `flex: 1` or have a fixed `width/height`.\n\n### Border radius\n\nThe `borderRadius` style is ignored by React Native custom view in Android and crashes on iOS. (read more [#1](https://github.com/douglasjunior/react-native-pdf-renderer/issues/1#issuecomment-1483395465))\n\nIf you need `borderRadius`, the best option is to wrap the `PdfRendererView` in another `View`.\n\n```jsx\n\u003cView style={{ flex: 1, borderRadius: 24, overflow: 'hidden' }}\u003e\n  \u003cPdfRendererView\n    // ...\n  /\u003e\n\u003c/View\u003e\n```\n\n### Android crash when zooming too much\n\nTo prevent Android from crashing when zooming too much, we have a `maxPageResolution` prop that limits the page resolution when zooming. (read more [#26](https://github.com/douglasjunior/react-native-pdf-renderer/issues/26))\n\nIf you are receiving the error `java.lang.RuntimeException: Canvas: trying to draw too large(134806560bytes) bitmap`, try to reduce the `maxPageResolution` prop.\n\n## Mock with jest\n\n```js\njest.mock('react-native-pdf-renderer', () =\u003e require('react-native-pdf-renderer/dist/mock'));\n```\n\n## Contribute\n\nNew features, bug fixes, and improvements are welcome! For questions and suggestions use the [issues](https://github.com/douglasjunior/react-native-pdf-renderer/issues).\n\n\u003ca href=\"https://www.patreon.com/douglasjunior\"\u003e\u003cimg src=\"http://i.imgur.com/xEO164Z.png\" alt=\"Become a Patron!\" width=\"200\" /\u003e\u003c/a\u003e\n[![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://paypal.me/douglasnassif)\n\n## Thanks to\n\nThis lib is only possible thanks to the community help:\n\n- RecyclerView `notifyDataSetChanged()` not working on React Native: https://stackoverflow.com/a/49381907/2826279\n- Add pinch to zoom on RecyclerView: https://stackoverflow.com/a/37895783/2826279\n- Using `Matrix` to handle zoom in a View: https://stackoverflow.com/a/55299327/2826279\n- [Daniel Felipe Sartório](https://github.com/danielfelipesartorio) for the help with Android native code\n\n## Star History\n\n[![Star History Chart](https://api.star-history.com/svg?repos=douglasjunior/react-native-pdf-renderer\u0026type=Date)](https://star-history.com/#douglasjunior/react-native-pdf-renderer)\n\n## License\n\n```\nThe MIT License (MIT)\n\nCopyright (c) 2023 Douglas Nassif Roma Junior\n```\n\nSee the full [license file](https://github.com/douglasjunior/react-native-pdf-renderer/blob/main/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdouglasjunior%2Freact-native-pdf-renderer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdouglasjunior%2Freact-native-pdf-renderer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdouglasjunior%2Freact-native-pdf-renderer/lists"}