# react-native-pdf-thumbnail

> Generate thumbnail for PDF files

Latest version **1.3.1** (published 2023-11-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-pdf-thumbnail
pnpm add react-native-pdf-thumbnail
yarn add react-native-pdf-thumbnail
bun add react-native-pdf-thumbnail
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.3.1 |
| Published | 2023-11-05 |
| First published | 2020-07-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >= 18.0.0 |
| Dependencies | 0 |
| Unpacked size | 27.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 48 |
| Author | Song Qian |
| Maintainers | songsterq |
| Keywords | react-native, pdf, thumbnail, ios, android |

## Links

- npm: https://www.npmjs.com/package/react-native-pdf-thumbnail
- Repository: https://github.com/songsterq/react-native-pdf-thumbnail
- Homepage: https://github.com/songsterq/react-native-pdf-thumbnail#readme
- Issues: https://github.com/songsterq/react-native-pdf-thumbnail/issues
- npm.io page: https://npm.io/package/react-native-pdf-thumbnail

## 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

- 1.3.1 (latest) — 2023-11-05
- 1.3.0 — 2023-11-05
- 1.2.1 — 2023-02-02
- 1.2.0 — 2022-10-21
- 1.1.0 — 2022-10-16
- 1.0.2 — 2020-12-09
- 1.0.1 — 2020-07-09
- 1.0.0 — 2020-07-09
- 0.3.0 — 2020-07-06
- 0.2.0 — 2020-07-06

## README

# react-native-pdf-thumbnail

A react native module for generating thumbnail for PDF files.

A wrapper for:
- PDFKit on iOS (requires iOS 11+)
- PdfRenderer on Android (requires API level 21 - LOLLIPOP)

No other JavaScript or native dependencies.

Note: This module **does not** work in Expo.

## Installation

```sh
npm install react-native-pdf-thumbnail
```

## Usage

```js
import PdfThumbnail from "react-native-pdf-thumbnail";

// For iOS, the filePath can be a file URL.
// For Android, the filePath can be either a content URI, a file URI or an absolute path.
const filePath = 'file:///mnt/sdcard/myDocument.pdf';
const page = 0;

// The thumbnail image is stored in caches directory, file uri is returned.
// Image dimensions are also available to help you display it correctly.
const { uri, width, height } = await PdfThumbnail.generate(filePath, page);

// Generate thumbnails for all pages, returning an array of the object above.
const results = await PdfThumbnail.generateAllPages(filePath);

// Default compression quality is 80, you can optionally specify a quality between 0 and 100.
const { uri, width, height } = await PdfThumbnail.generate(filePath, page, 95);
const results = await PdfThumbnail.generateAllPages(filePath, 90);
```

## Demo

The example app contains a document picker, it generates and displays a thumbnail for the selected PDF file.

To run it:
```sh
yarn
yarn example ios
yarn example android
```

iOS | Android
------- | ---
![86563759-d103db80-bf19-11ea-98a2-77788efe4938](https://user-images.githubusercontent.com/3325682/86644851-bfaae580-bf92-11ea-8b2b-f065784b3425.png) | ![86564313-dca3d200-bf1a-11ea-99fe-6f08a3302b20](https://user-images.githubusercontent.com/3325682/86644858-c174a900-bf92-11ea-8a01-79476b1050a1.png)

## Contributing

See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.

## License

MIT

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