react-pdf-viewer v2.2.0 Release Notes

Release Date: 2020-11-10 // over 3 years ago
  • ๐Ÿ†• New features

    • ๐Ÿ‘Œ Support loading PDF from a protected resource with new authorization option.
    import { Viewer } from '@react-pdf-viewer/core';
    
    <Viewer
        fileUrl={...}
        authorization='Bearer ...'
    />
    

    If you want to use another authorization servers or send more additional authentication headers, then use the new httpHeaders option, for example:

    import { Viewer } from '@react-pdf-viewer/core';
    
    <Viewer
        fileUrl={...}
        authorization='...'
        httpHeaders={{
            key: value,
        }}
    />
    
    • It's possible to customize the search control with the new Search component:
    import { RenderSearchProps, Search } from '@react-pdf-viewer/search';
    
    <Search>
    {
        (renderSearchProps: RenderSearchProps) => (
            // Your custom search control
        )
    }
    </Search>
    

    ๐Ÿ— The parameter renderSearchProps provides the properties and methods to build up a custom search control:

    Property Type Description
    clearKeyword Function Clear the keyword
    changeMatchCase Function The result has to match case with the keyword
    changeWholeWords Function The result has to match the whole keyword
    currentMatch number The index of current match
    jumpToNextMatch Function Jump to the next match
    jumpToPreviousMatch Function Jump to the previous match
    keyword string The current keyword
    matchCase boolean true if the result matches case with the keyword
    wholeWords boolean true if the result matches the whole keyword
    search Function Perform the search with current keyword and matchCase, wholeWords conditions
    setKeyword Function Set the current keyword

    ๐Ÿ‘Œ Improvements

    • A current match search has a custom class rpv-search-text-highlight-current. So you can customize the current match by adding CSS properties for the class.
    • Avoid the black flickering when clicking a bookmark
    • ๐Ÿ‘Œ Support both React v16 and v17

    ๐Ÿ› Bug fixes

    • 0๏ธโƒฃ The print plugin doesn't work with default-layout plugin
    • ๐Ÿ–จ In some cases, there is an extra blank page when printing
    • ๐Ÿ”Œ Clicking bookmark doesn't jump to correct page in horizontal scroll mode
    • ๐Ÿ”Œ Jumping between search match doesn't work properly in horizontal scroll mode

    ๐Ÿ’ฅ Breaking changes

    • ๐Ÿšš The onCanvasLayerRender option is removed. Instead, use the onCanvasLayerRender option in your plugin.
    • The TextLayerRenderStatus enum is renamed to LayerRenderStatus.