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