Socket
Socket
Sign inDemoInstall

react-native-pdf-thumbnail

Package Overview
Dependencies
514
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-native-pdf-thumbnail

Generate thumbnail for PDF files


Version published
Weekly downloads
4.1K
increased by5.9%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

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

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

// 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:

yarn
yarn example ios
yarn example 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

Keywords

FAQs

Last updated on 05 Nov 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc