The
print plugin comes with the
`PrintButton`
and
`Print`
components which can be used to print the document when users click on. Scroll to the
See also section at the bottom to link to the detailed examples if you want to know more.
If those abilities are not enough for you, then you can trigger print by calling the `print`
function directly.
import { printPlugin } from '@react-pdf-viewer/print';
const printPluginInstance = printPlugin();
const { print } = printPluginInstance;
import { defaultLayoutPlugin } from '@react-pdf-viewer/default-layout';
const defaultLayoutPluginInstance = defaultLayoutPlugin();
const { print } = defaultLayoutPluginInstance.toolbarPluginInstance.printPluginInstance;
The following example demonstrates a very basic usage where users can click on your own button to print the current document:
<button onClick={print}>Print</button>
See also