`Zoom`
component comes in handy:import { zoomPlugin } from '@react-pdf-viewer/zoom';const zoomPluginInstance = zoomPlugin();const { Zoom } = zoomPluginInstance;
`RenderZoomProps`
and returns a React element.`RenderZoomProps`
provides the following properties:Property | Type | Description | From |
---|---|---|---|
`scale` | `number` | The current scale level | 2.0.0 |
`onZoom` | `Function` | Zoom to specific level | 2.0.0 |
`onZoom`
is a function that takes a `number | SpecialZoomLevel`
parameter.`SpecialZoomLevel`
is an enum of three possible values:Value | Description |
---|---|
`ActualSize` | Zoom to actual size of page |
`PageFit` | Fit the pages in the container |
`PageWidth` | Fit the width of pages in the container |
import { SpecialZoomLevel } from '@react-pdf-viewer/core';import { RenderZoomProps } from '@react-pdf-viewer/zoom';// Your render function<Zoom>{(props: RenderZoomProps) => (<buttonstyle={{...}}onClick={() => props.onZoom(2.0)}>150%</button>)}</Zoom><Zoom>{(props: RenderZoomProps) => (<buttonstyle={{...}}onClick={() => props.onZoom(SpecialZoomLevel.ActualSize)}>Actual size</button>)}</Zoom>