# @react-pdf-viewer/get-file

> A React component to view a PDF document

Latest version **3.12.0** (published 2023-03-21) · https://react-pdf-viewer.dev/license license · 0 weekly downloads

## Install

```sh
npm install @react-pdf-viewer/get-file
pnpm add @react-pdf-viewer/get-file
yarn add @react-pdf-viewer/get-file
bun add @react-pdf-viewer/get-file
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.12.0 |
| Published | 2023-03-21 |
| First published | 2020-10-18 |
| Weekly downloads | 0 |
| License | https://react-pdf-viewer.dev/license |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 15 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2599 |
| Author | Nguyen Huu Phuoc |
| Maintainers | phuoc-ng |
| Keywords | react, react.js, pdf, pdf.js, pdf viewer |

## Links

- npm: https://www.npmjs.com/package/@react-pdf-viewer/get-file
- Repository: https://github.com/react-pdf-viewer/react-pdf-viewer
- Homepage: https://react-pdf-viewer.dev
- Issues: https://github.com/react-pdf-viewer/react-pdf-viewer/issues
- npm.io page: https://npm.io/package/@react-pdf-viewer/get-file

## Dependencies (1)

- [@react-pdf-viewer/core](https://npm.io/package/@react-pdf-viewer/core.md) 3.12.0

## Alternatives

- [@cantoo/pdf-lib](https://npm.io/package/@cantoo/pdf-lib.md) — 297.9K weekly downloads
- [datatables.net-buttons](https://npm.io/package/datatables.net-buttons.md) — 200.1K weekly downloads
- [@ckeditor/ckeditor5-export-pdf](https://npm.io/package/@ckeditor/ckeditor5-export-pdf.md) — 167.0K weekly downloads
- [scanbot-web-sdk](https://npm.io/package/scanbot-web-sdk.md) — 15.0K weekly downloads
- [@syncfusion/ej2-angular-pdfviewer](https://npm.io/package/@syncfusion/ej2-angular-pdfviewer.md) — 8.8K weekly downloads

## Recent versions

- 3.12.0 (latest) — 2023-03-21
- 3.11.0 — 2023-01-27
- 3.10.0 — 2022-12-28
- 3.9.0 — 2022-11-30
- 3.8.0 — 2022-11-09
- 3.7.0 — 2022-08-21
- 3.6.0 — 2022-06-27
- 3.5.0 — 2022-06-14
- 3.4.0 — 2022-06-06
- 3.3.3 — 2022-05-31
- 3.3.2 — 2022-05-08
- 3.3.1 — 2022-05-02
- 3.3.0 — 2022-04-19
- 3.2.0 — 2022-04-03
- 3.1.2 — 2022-03-08
- … 27 more at https://npm.io/package/@react-pdf-viewer/get-file/versions

## README

# download plugin

This plugin allows user to download the current file.

```javascript
import { downloadPlugin } from '@react-pdf-viewer/download';

const downloadPluginInstance = downloadPlugin();

// The button to download the current file
const { Download } = downloadPluginInstance;

// Render
return (
    <>
    <Download />
    <Viewer
        plugins={[
            downloadPluginInstance,
        ]}
    >
    </>
);
```

## Use a custom button

```javascript
import { downloadPlugin } from '@react-pdf-viewer/download';

const downloadPluginInstance = downloadPlugin();

// The button to download the current file
const { Download } = downloadPluginInstance;

// Render
return (
    <>
    <Download>
    {
        (props) => (
            // Your custom button here
            <button onClick={props.onClick}>
                Download
            </button>
        )
    }
    </Download>
    <Viewer
        plugins={[
            downloadPluginInstance,
        ]}
    >
    </>
);
```

## Plugin options

-   `fileNameGenerator` (Optional): Custom the name of download file.

It is a function accepts the current opened file and returns a `string`:

```javascript
(file: OpenFile) => string;
```

By default, the name of download file is determined by the `name` properties of `OpenFile`.
You can customize it as following:

```javascript
import { OpenFile } from '@react-pdf-viewer/core';

const downloadPluginInstance = downloadPlugin({
    fileNameGenerator: (file: OpenFile) => {
        // `file.name` is the URL of opened file
        const fileName = file.name.substring(file.name.lastIndexOf('/') + 1);
        return `a-copy-of-${fileName}`;
    },
});
```

---
_Source: https://npm.io/package/@react-pdf-viewer/get-file · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
