npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-native-pdf-to-image

v4.0.0

Published

A react native plugin to convert PDF pages to images

Readme

react-native-pdf-to-image

Convert PDF pages into PNG images from React Native.

The library exposes native methods for:

  • converting a PDF file URI into cached PNG images
  • converting a base64-encoded PDF into cached PNG images
  • sending a base64 PDF payload to a socket printer

Features

  • supports Android and iOS
  • returns one output image path per PDF page
  • writes generated images into the app cache directory
  • works with local file URIs and copied document-picker files

Installation

npm install react-native-pdf-to-image

If you are using iOS, install pods after adding the package:

cd ios && pod install

Requirements

  • React Native app with native modules enabled
  • not supported in Expo Go
  • on iOS, rebuild the app after installation

API

convert(uri: string): Promise<{ outputFiles: string[] | undefined }>

Converts a PDF referenced by a local URI into PNG files.

import { convert } from 'react-native-pdf-to-image';

const result = await convert('file:///path/to/document.pdf');

console.log(result.outputFiles);
// ['/.../Library/Caches/1713370000000-1_pdf.png', ...]

convertB64(base64Str: string, dpi: number): Promise<{ outputFiles: string[] | undefined }>

Converts a base64-encoded PDF string into PNG files.

The dpi argument is used as the target output width for the rendered page images.

import { convertB64 } from 'react-native-pdf-to-image';

const result = await convertB64(pdfBase64String, 1024);

console.log(result.outputFiles);
// ['/cache/...png', '/cache/...png']

printPDF(ip: string, port: number, base64Str: string): Promise<number>

Sends a base64-encoded PDF directly to a socket printer.

import { printPDF } from 'react-native-pdf-to-image';

await printPDF('192.168.0.25', 9100, pdfBase64String);

Example

The example app uses react-native-document-picker to let the user choose a PDF, copies it into the cache directory, then passes the copied file URI into convert().

import DocumentPicker from 'react-native-document-picker';
import { convert } from 'react-native-pdf-to-image';

const docs = await DocumentPicker.pick({
  type: DocumentPicker.types.pdf,
  copyTo: 'cachesDirectory',
});

if (docs.length) {
  const uri = docs[0]?.fileCopyUri || '';
  const result = await convert(uri);
  console.log(result.outputFiles);
}

Notes

  • outputFiles contains absolute file paths for the generated PNG images.
  • Generated files are written to the app cache directory, so you should move them if you need long-term storage.
  • File URIs are the most reliable input for convert().
  • Large PDFs can produce many images, so watch cache usage if you convert frequently.

Troubleshooting

If you see a linking error:

  • run pod install on iOS
  • rebuild the app after installing the package
  • confirm you are not running inside Expo Go

If the example app fails during pod install on older React Native 0.72 setups, the bundled Boost mirror may need to be rewritten during CocoaPods install. The example project in this repository already includes that workaround.

Contributing

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

License

MIT