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 keywordwholeWords
boolean
true
if the result matches the whole keywordsearch
Function
Perform the search with current keyword
andmatchCase
,wholeWords
conditionssetKeyword
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 theonCanvasLayerRender
option in your plugin. - The
TextLayerRenderStatus
enum is renamed toLayerRenderStatus
.
- ๐ Support loading PDF from a protected resource with new