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';

Usage

  • Import the plugin:
import { getFilePlugin } from '@react-pdf-viewer/get-file';
  • 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
DownloadMenuItem  ReactElementThe default download menu item2.5.0
  • Finally, register the get-file plugin instance:
<Viewer
    fileUrl='...'
    plugins={[
        getFilePluginInstance,
    ]}
/>

Examples