pdf-viewer-reactjs
Simple react PDF Viewer component with controls like
- Page navigation
- Zoom
- Rotation
Every element can be styled upon your preferences using default classes your own and also custom react element can be passed.
Initially it was forked from mgr-pdf-viewer-react
Hit the :star: in gihub if you like it
Example: Live demo is available here
How to install
npm install pdf-viewer-reactjs
Note:
Due to causing broken css issue bulma, bulma-helpers & material-design-icons are removed from dependencies and added as peerDependencies
Please install bulma, bulma-helpers & material-design-icons from npm by yourself or provide custom css as per your requirement
How to use
import React from 'react'
import PDFViewer from 'pdf-viewer-reactjs'
const ExamplePDFViewer = () => {
return (
<PDFViewer
document={{
url: 'https://arxiv.org/pdf/quant-ph/0410100.pdf',
}}
/>
)
}
export default ExamplePDFViewer
Documentation
React component prop. types:
document
:
PropTypes.shape({
url: String,
base64: String,
})
password
:
withCredentials
:
externalInput
:
-
Type: Boolean
-
Required: false
-
Description: By default page number, scale and rotation angle can be set initially using the props but cannot be changed dynamically, to make these props dynamic pass this prop (after passing this prop navbar will become hidden)
page
:
scale
:
rotationAngle
:
-
Type: Number
-
Required: false
-
Description: Initial rotation of the document, values can be -90, 0 or 90, also can be used to change the rotation angle dynamically after passing externalInput
prop
scaleStep
:
minScale
:
maxScale
:
onDocumentClick
:
onPrevBtnClick
:
onNextBtnClick
:
onZoom
:
onRotation
:
getMaxPageCount
:
css
:
canvasCss
:
navbarOnTop
:
hideNavbar
:
hideZoom
:
hideRotation
:
loader
:
alert
:
showThumbnail
:
PropTypes.shape({
scale: PropTypes.number,
rotationAngle: PropTypes.number,
onTop: PropTypes.bool,
backgroundColor: PropTypes.string,
thumbCss: PropTypes.string,
selectedThumbCss: PropTypes.string,
})
protectContent
:
watermark
:
PropTypes.shape({
text: PropTypes.string,
diagonal: PropTypes.bool,
opacity: PropTypes.string,
font: PropTypes.string,
size: PropTypes.string,
color: PropTypes.string,
})
navigation
:
PropTypes.oneOfType([
PropTypes.shape({
css: PropTypes.shape({
navbarWrapper: String,
zoomOutBtn: String,
resetZoomBtn: String,
zoomInBtn: String,
previousPageBtn: String,
pageIndicator: String,
nextPageBtn: String,
rotateLeftBtn: String,
resetRotationBtn: String,
rotateRightBtn: String
})
PropTypes.any
]);
Author
Ansuman Ghosh
ansu5555.com