react-pdf-viewer v1.4.0 Release Notes
Release Date: 2020-03-13 // about 4 years ago-
๐ New features
- โ Add new optional parameter indicating the page that will be displayed initially
<Viewer // The page is zero-based index // We will display the third page initially initialPage={2} />
- โ Add new optional parameter to define the prefix of CSS classes
<Viewer prefixClass='viewer' />
- โ Add new
render
parameter that includes many functions that could be called from outside of the component:
import Viewer, { RenderViewerProps, ScrollMode, SpecialZoomLevel, SelectionMode } from '@phuocng/react-pdf-viewer'; const render = (props: RenderViewerProps) => { return ( <div> <div style={{ height: '500px' }}> {props.viewer} </div> <button onClick={() => props.jumpToPage(props.doc.numPages - 1)}>Jump to last page</button> <button onClick={() => props.rotate(90)}>Rotate +90 degrees</button> <button onClick={() => props.zoom(0.5)}>Zoom to 50%</button> <button onClick={() => props.zoom(SpecialZoomLevel.ActualSize)}>Zoom to actual size</button> <button onClick={() => props.changeScrollMode(ScrollMode.Wrapped)}>Switch to wrapped scrolling</button> <button onClick={() => props.changeSelectionMode(SelectionMode.Hand)}>Switch to hand tool</button> <button onClick={() => props.print()}>Print</button> <button onClick={() => props.download()}>Download</button> </div> ); }; <Viewer fileUrl='/path/to/document.pdf' render={render} />
๐ Improvement
- ๐ All styles are moved to external CSS files. It's possible for us to override components' styles.
๐ Bug fixes
- ๐จ Can't scroll and print on IE 11
- ๐จ Printing doesn't look good if the page size isn't set
- ๐จ Blank page when print the current web page