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
`fileNameGenerator``OpenFile => String`Generate the name of download file2.0.0
The plugin instance `getFilePluginInstance` provides the following properties:
PropertyTypeDescriptionFrom
`Download``ReactElement`Customizable download button2.0.0
`DownloadButton``ReactElement`The default download button2.0.0
`DownloadMenuItem``ReactElement`The default download menu item2.5.0
3. Register the plugin
Finally, register the `get-file` plugin instance:
<Viewer plugins={[getFilePluginInstance]} />

Properties

The `get-file` plugin provides other useful property as following:
import { DownloadIcon } from '@react-pdf-viewer/open';
PropertyTypeDescriptionFrom
`DownloadIcon``ReactElement`The download file icon2.0.0

See also

Changelog

v3.6.0
  • Update the `DownloadIcon` component
v2.11.0
  • Downloading document doesn't work on iOS Safari and iOS Chrome
  • Keep the file name when downloading a file opened from local
  • The plugin doesn't work with a file which is opened with credentials
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