Licence
MIT
Version
0.0.2
Deps
2
Size
16.8 MB
Vulns
1
Weekly
0
A pdf viewer

See sourcecodes in github to get more information.
Usage
Install
yarn add @lemon-clown-wpg/react-pdf-viewer # you aslo should install peerDependencies if the terminal prompts for a warnningUse in React project
import React from 'react' import ReactDOM from 'react-dom' import { PDFViewer } from '@lemon-clown-wpg/react-pdf-viewer' import '@lemon-clown-wpg/react-pdf-viewer/lib/esm/index.css' const pdfStyle: React.CSSProperties = { width: '100vw', height: '100vh', } // index.tsx ReactDOM.render( <PDFViewer style={ pdfStyle } fileUrl="/files/demo.pdf" /> , document.getElementById('root') )
Options
| property | required | type | default |
|---|---|---|---|
| fileUrl | true |
string |
|
| fileName | false |
string |
`/(?:[^/\][/\])?([^/\]+?)(?:#[\s\S])?$/.exec(fileUrl)[1] |
| direction | false |
`'ltr' | 'rtr'` |
| MIN_SCALING | false |
number |
0.50 |
| MAX_SCALING | false |
number |
4.00 |
| ZOOM_STEP | false |
number |
0.10 |
| selectOptions | false |
number[] |
[ 0.50, 0.75, 1.00, 1.25, 1.50, 2.00, 3.00, 4.00 ] |
| onDocumentLoadError | false |
Function |
undefined |
| onDocumentLoadSuccess | false |
Function |
undefined |
fileUrl: url of pdf filefileName: filename of pdf filedirection: the text directionMIN_SCALING: minimum scalingMAX_SCALING: maximum scalingZOOM_STEP: the size of the zoom stepscaleOptions: Options for the drop-down boxonDocumentLoadError: Function called in case of an error while loading a document.onDocumentLoadError?: (error: Error) => void
onDocumentLoadSuccess: Function called when the document is successfully loaded.onDocumentLoadSuccess?: (pdf: pdfjs.PDFDocumentProxy) => void