react-pdf-viewer v1.7.0-dev Release Notes
-
๐ New features
- โ Add
onPageChange
callback that is invoked when user changes page:
import Viewer, { PageChangeEvent } from '@phuocng/react-pdf-viewer'; const handlePageChange = (e: PageChangeEvent) => { console.log(`Changed to page: ${e.currentPage}`) }; <Viewer fileUrl='/path/to/document.pdf' onPageChange={handlePageChange} />
- โ Add
onCanvasLayerRender
event that is invoked when the canvas layer is rendered completely.
import Viewer, { CanvasLayerRenderEvent } from '@phuocng/react-pdf-viewer'; const onCanvasLayerRender = (e: CanvasLayerRenderEvent) => { // `e.ele` is the canvas element const canvas = e.ele; // Do something with the canvas element }; <Viewer fileUrl='/path/to/document.pdf' onCanvasLayerRender={onCanvasLayerRender} />
- โ Add
onTextLayerRender
event that is invoked when the text layer is ready.
import Viewer, { TextLayerRenderEvent } from '@phuocng/react-pdf-viewer'; const onTextLayerRender = (e: TextLayerRenderEvent) => { // For example, we can find all text elements that look like a link, // and replace it with `a` elements }; <Viewer fileUrl='/path/to/document.pdf' onTextLayerRender={onTextLayerRender} />
- ๐ Support non-latin characters via the
characterMap
option
import Viewer, { CharacterMap } from '@phuocng/react-pdf-viewer'; const characterMap: CharacterMap = { isCompressed: true, url: 'https://unpkg.com/[email protected]/cmaps/', }; <Viewer characterMap={characterMap} fileUrl='/path/to/document.pdf' />
๐ Bug fixes
- The viewer doesn't jump to the destination or searching result exactly
๐ฅ Breaking changes
The parameters of
onDocumentLoad
andonZoom
are changed as following:v1.6.0 v1.7.0 onDocumentLoad(doc)
onDocumentLoad({ doc })
onZoom(doc, scale)
onDocumentLoad({ doc, scale })
- โ Add