Get File plugin

The get-file plugin provides a button that can be used to download the PDF document. It is able to customize the download button as well.

Install

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

Usage

1. Import the plugin
import { getFilePlugin } from '@react-pdf-viewer/get-file';
2. Create the plugin instance
const getFilePluginInstance = getFilePlugin(props?: GetFilePluginProps);
The getFilePlugin() function takes a GetFilePluginProps parameter that consists of the following property:
PropertyTypeDescriptionFrom
fileNameGeneratorOpenFile => StringGenerate the name of download file2.0.0
The plugin instance getFilePluginInstance provides the following properties:
PropertyTypeDescriptionFrom
DownloadReactElementCustomizable download button2.0.0
DownloadButtonReactElementThe default download button2.0.0
DownloadMenuItemReactElementThe default download menu item2.5.0
3. Register the plugin
Finally, register the get-file plugin instance:
<Viewer plugins={[getFilePluginInstance]} />

See also

Changelog

v2.4.2
  • When users download a document loaded with Uint8Array, the download file is named as document.pdf instead of the document blob
v2.4.1
  • Clicking the Download button doesn't work. It only works the file when scrolling to the second page
v2.0.0
  • First release