{"id":17235341,"url":"https://github.com/alpha0010/react-native-pdf-viewer","last_synced_at":"2026-03-02T22:22:40.510Z","repository":{"id":38537324,"uuid":"296458053","full_name":"alpha0010/react-native-pdf-viewer","owner":"alpha0010","description":"Minimalist PDF viewer for React Native","archived":false,"fork":false,"pushed_at":"2024-09-23T15:37:35.000Z","size":608,"stargazers_count":79,"open_issues_count":3,"forks_count":11,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-04T12:29:47.915Z","etag":null,"topics":["pdf","pdf-viewer","react-native"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/alpha0010.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}},"created_at":"2020-09-17T22:44:48.000Z","updated_at":"2025-02-27T02:29:04.000Z","dependencies_parsed_at":"2024-06-19T00:18:40.048Z","dependency_job_id":"0f80edad-03e4-4a96-afe3-3d8c46ae01e8","html_url":"https://github.com/alpha0010/react-native-pdf-viewer","commit_stats":{"total_commits":105,"total_committers":2,"mean_commits":52.5,"dds":0.02857142857142858,"last_synced_commit":"c61347714c59a5bf97a2b32b48dde991ec1250e9"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alpha0010%2Freact-native-pdf-viewer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alpha0010%2Freact-native-pdf-viewer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alpha0010%2Freact-native-pdf-viewer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alpha0010%2Freact-native-pdf-viewer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alpha0010","download_url":"https://codeload.github.com/alpha0010/react-native-pdf-viewer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247767239,"owners_count":20992548,"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":["pdf","pdf-viewer","react-native"],"created_at":"2024-10-15T05:33:06.043Z","updated_at":"2026-03-02T22:22:40.501Z","avatar_url":"https://github.com/alpha0010.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-native-pdf-light\n\n[![npm version](https://img.shields.io/npm/v/react-native-pdf-light)](https://www.npmjs.com/package/react-native-pdf-light)\n![CI](https://github.com/alpha0010/react-native-pdf-viewer/workflows/CI/badge.svg)\n\nPDF viewer for React Native. Implemented with platform native render functions\nfor smallest deploy size impact, and restricted feature set to simplify\nintegration with larger systems.\n\nIncludes prefabricated full document viewer based on `FlatList` and a single\npage render component to use as a building block for your own fully custom\nviewer.\n\nUses `android.graphics.pdf.PdfRenderer` on Android and `CGPDFDocument` on iOS.\nUnlike many native components in the wild, `react-native-pdf-light` provides\nfull implementation of React Native shadow nodes. This simplifies UI\ndevelopment, since the component actually knows its own dimensions.\n\nVersion 2.x, adds render support for annotations conforming the\n[PAS standard v1](https://github.com/alpha0010/paged-annotation). If\nannotation support is not needed, use 1.x for slightly reduced size.\n\n\u003cimg src=\"docs/annotation.png\" alt=\"PDF Annotation\" height=\"400\"\u003e\n\n## Installation\n\n```sh\nnpm install react-native-pdf-light\n```\n\nIf iOS build fails with `Undefined symbol: __swift_FORCE_LOAD_...`, add an\nempty `.swift` file to the xcode project.\n\n### Compatibility\n\n| React Native | react-native-pdf-light |\n| ------------ | ---------------------- |\n| old arch     | 1.x.x, 2.x.x           |\n| new arch     | 3.x.x                  |\n\n## Usage\n\n```js\nimport { Pdf, PdfUtil } from 'react-native-pdf-light';\n\nPdfUtil.getPageCount(source).then(console.log);\n\n\u003cPdf source={source} /\u003e\n```\n\nIf creating your own custom viewer to manage pages:\n```js\nimport { PdfView } from 'react-native-pdf-light';\n\n\u003cPdfView page={page} source={source} /\u003e\n```\n\nFor zoom support, install `react-native-gesture-handler` and use deep import.\nNote that `react-native-gesture-handler` is only required to use zoom\nfeatures; the other display options do not have any dependencies.\n```js\nimport { ZoomPdfView } from 'react-native-pdf-light/Zoom';\n\n\u003cZoomPdfView page={page} source={source} /\u003e\n```\n\n#### `\u003cPdf ... /\u003e` Display a pdf.\n\nProps:\n- `annotation: string`\n  - Optional: Path to annotation data. File assumed to be [PAS v1](https://github.com/alpha0010/paged-annotation#version-1).\n- `annotationStr: string`\n  - Optional: Stringified JSON of annotation data. Data assumed to be [PAS v1](https://github.com/alpha0010/paged-annotation#version-1).\n- `onError: (error: Error) =\u003e void`\n  - Optional: Callback to handle errors.\n- `onLoadComplete: (numberOfPages: number) =\u003e void`\n  - Optional: Callback to handle pdf load completion.\n  - Passed the page count of the loaded pdf.\n- `onMeasurePages: (measurements: { itemHeight: number, offset: number }[]) =\u003e void`\n  - Optional: Callback to receive layout details of all pages.\n- `shrinkToFit: 'never' | 'portrait' | 'landscape' | 'always'`\n  - Optional: Size pages such that each page can be displayed without cutoff.\n  - Applies when device is in the specified orientation.\n- `source: string`\n  - Document to display.\n\nThe following props are forwarded to the underlying\n[`FlatList`](https://reactnative.dev/docs/flatlist) component:\n- `initialScrollIndex`\n- `ListEmptyComponent`\n- `onMomentumScrollBegin`\n- `onMomentumScrollEnd`\n- `onScroll`\n- `onScrollBeginDrag`\n- `onScrollEndDrag`\n- `refreshControl`\n- `scrollEventThrottle`\n\nMethods:\n- `scrollToIndex(index: number): void`\n  - Scroll to the specified page (0-indexed).\n- `scrollToOffset(offset: number): void`\n  - Scroll to the specified offset.\n\n#### `\u003cPdfView ... /\u003e` Single page of a pdf.\n\nProps:\n- `annotation: string`\n  - Optional: Path to annotation data. File assumed to be [PAS v1](https://github.com/alpha0010/paged-annotation#version-1).\n- `annotationStr: string`\n  - Optional: Stringified JSON of annotation data. Data assumed to be [PAS v1](https://github.com/alpha0010/paged-annotation#version-1).\n- `page: number`\n  - Page (0-indexed) of document to display.\n- `resizeMode: 'contain' | 'fitWidth'`\n  - Optional: How pdf page should be scaled to fit in view dimensions.\n- `source: string`\n  - Document to display.\n- `style: ViewStyle`\n  - Optional: View stylesheet.\n\n#### `\u003cZoomPdfView ... /\u003e` Pinch zoomable single page of a pdf.\n\nZoom interactions compatible with `react-native-pager-view` in horizontal\ndisplay mode.\n\nProps:\n- All props from `PdfView`\n- `onZoomIn: () =\u003e void`\n  - Optional: Callback when view starts to zoom.\n- `onZoomReset: () =\u003e void`\n  - Optional: Callback when view returns to non-zoomed state.\n- `maximumZoom: number`\n  - Optional: Maximum allowed zoom. Default 2.\n- `refreshControl: \u003cRefreshControl /\u003e`\n  - Optional: A [`RefreshControl`](https://reactnative.dev/docs/refreshcontrol) component, used to provide pull-to-refresh functionality for the internal ScrollView.\n\n#### `PdfUtil` Utility functions.\n\n`PdfUtil.getPageCount(source: string): Promise\u003cnumber\u003e`\n- Get the number of pages of a pdf.\n\n`PdfUtil.getPageSizes(source: string): Promise\u003c{ height: number; width: number }[]\u003e`\n- Get the dimensions of every page.\n\n## Known Issues\n\nOn Android API level \u003c 26 when directly rendering pages with `PdfView` at a\nnon-default aspect ratio (e.g. setting both width and height of the view such\nthat the view's aspect ratio does not match the pdf page's aspect ratio) if\na page in the pdf is cropped or rotated, the page\nmay render in the wrong position. This is due to a bug in the native\n`android.graphics.pdf.PdfRenderer`. (If you are aware of a fix,\n[pull requests welcome](https://github.com/alpha0010/react-native-pdf-viewer/pulls).)\n\n## Alternatives\n\n- [react-native-pdf](https://github.com/wonday/react-native-pdf)\n- [react-native-file-viewer](https://github.com/vinzscam/react-native-file-viewer)\n- [react-native-view-pdf](https://github.com/rumax/react-native-PDFView)\n- [rn-pdf-reader-js](https://github.com/xcarpentier/rn-pdf-reader-js)\n\n## Contributing\n\nSee the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falpha0010%2Freact-native-pdf-viewer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falpha0010%2Freact-native-pdf-viewer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falpha0010%2Freact-native-pdf-viewer/lists"}