rpp
rn-pdf-png
npm i rn-pdf-png
rpp

rn-pdf-png

react native module for generating thumbnail for PDF files

by Song Qian

1.0.5 (see all)License:MITTypeScript:Built-In
npm i rn-pdf-png
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 needed.

Installation

npm install react-native-pdf-thumbnail

Usage

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

Demo

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

To run it:

yarn bootstrap
cd example
yarn ios
yarn android
iOSAndroid
86563759-d103db80-bf19-11ea-98a2-77788efe493886564313-dca3d200-bf1a-11ea-99fe-6f08a3302b20

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

Downloads/wk

34

GitHub Stars

16

LAST COMMIT

1yr ago

MAINTAINERS

1

CONTRIBUTORS

3

OPEN ISSUES

1

OPEN PRs

0
VersionTagPublished
1.0.5
latest
8mos ago
No alternatives found
No tutorials found
Add a tutorial
No dependencies found

Rate & Review

100
No reviews found
Be the first to rate