react-pdf-viewer v2.7.2 Release Notes

  • ๐Ÿ†• New feature

    ๐Ÿ”Œ The Search plugin provides new function named setTargetPages which sets the pages that you want to search in.

    import { searchPlugin } from '@react-pdf-viewer/search';
    
    const searchPluginInstance = searchPlugin();
    const { setTargetPages } = searchPluginInstance;
    
    // Only search in even pages
    setTargetPages((targetPage) => targetPage.pageIndex % 2 === 0);
    
    // Only search in the page 4
    setTargetPages((targetPage) => targetPage.pageIndex === 3);
    

    ๐Ÿ‘Œ Improvements

    • Allow to change the theme from outside of the Viewer component
    • 0๏ธโƒฃ When the default scale is set to a special zoom level, we should keep it when resizing the window
    • ๐Ÿ”Œ The onDocumentLoad event and plugins' PluginOnDocumentLoad callback provide access to the current opened file which contains the data and name properties:
    const handleDocumentLoad = (e: DocumentLoadEvent) => {
        console.log(e.file.name, e.file.data);
    };
    
    <Viewer onDocumentLoad={handleDocumentLoad} />;
    

    ๐Ÿ› Bug fixes

    • ๐Ÿ’ป Can't close the menu when using with the Fluent UI
    • 0๏ธโƒฃ The activateTab() method provided by the default layout plugin shouldn't toggle the tab
    • โšก๏ธ The LocalePopover component doesn't update the localization
    • 0๏ธโƒฃ The pages' container overflows on initial render when setting the default scale to SpecialZoomLevel.PageWidth