A React component to view a PDF document. It’s written in TypeScript, and powered by React hooks completely.
Basic features
Customization
Coming soon
Perform the following steps to have the simplest example. For more demos, please look at the demo folder.
$ npm install @phuocng/react-pdf-viewer
$ npm install pdfjs-dist
import Viewer, { Worker } from '@phuocng/react-pdf-viewer';
import '@phuocng/react-pdf-viewer/cjs/react-pdf-viewer.css';
<Worker workerUrl="https://unpkg.com/pdfjs-dist@2.2.228/build/pdf.worker.min.js">
<div style={{ height: '750px' }}>
<Viewer fileUrl="/path/to/document.pdf" />
</div>
</Worker>
$ npm run build
Then it will produce two formats available in the dist
folder:
└─── dist
├─── cjs // CommonJS package
└─── umd // UMD package
$ npm run lint
It will check if the entire source code compatible with TSLint. The tslint.log
file will let us know if there’s any file which doesn’t pass the checks.
Author: phuoc-ng
Official Website: https://github.com/phuoc-ng/react-pdf-viewer
#reactjs #javascript