Print plugin

The print plugin provides a button to print the current PDF document. It is possible to customize the button as well.

Install

npm install '@react-pdf-viewer/print';
The print plugin is included in the toolbar and default-layout plugins

Usage

  • Import the plugin and styles:
import { printPlugin } from '@react-pdf-viewer/print';
// Import styles
import '@react-pdf-viewer/print/lib/styles/index.css';
  • Create the plugin instance:
const printPluginInstance = printPlugin(props?: PrintPluginProps);
The printPlugin() function takes an optional PrintPluginProps parameter that consists of the following property:
PropertyTypeDescriptionFrom
enableShortcutsbooleanEnable shortcuts2.6.0
By default, the shortcut is enabled. Users can press ctrl + p to print the current document.
The plugin instance printPluginInstance provides the following properties:
PropertyTypeDescriptionFrom
PrintReactElementCustomizable print button2.0.0
PrintButtonReactElementThe default print button2.0.0
PrintMenuItemReactElementThe default print menu item2.5.0
  • Finally, register the print plugin instance:
<Viewer fileUrl="..." plugins={[printPluginInstance]} />

Properties

The print plugin provides other useful property as following:
import { PrintIcon } from '@react-pdf-viewer/print';
PropertyTypeDescriptionFrom
PrintIconReactElementThe print icon2.0.0

Examples