expo-pdf-to-image
v1.0.0
Published
An Expo module for iOS & Android that converts PDF files into JPEG images
Downloads
141
Maintainers
Readme
expo-pdf-to-image
An Expo module that converts PDF files to JPEG images. Each page of the PDF is rendered as a separate image and stored in the app's cache directory.
Platform Support
| iOS | Android | Web | |-----|---------|-----| | ✓ | ✓ | ✗ |
Web is not supported. Calling
convertPdfToImageson web will throw an error.
Installation
npm install expo-pdf-to-imageExpo (Managed Workflow)
npx expo prebuildBare React Native
Run npx pod-install after installing.
Usage
import ExpoPdfToImageModule from 'expo-pdf-to-image';
const imagePaths = await ExpoPdfToImageModule.convertPdfToImages('/path/to/file.pdf');
// imagePaths is an array of local file paths, one per PDF page
// e.g. ['/cache/pdf_page_0.jpg', '/cache/pdf_page_1.jpg', ...]API
convertPdfToImages(pdfPath: string): Promise<string[]>
Converts all pages of a PDF to JPEG images.
| Parameter | Type | Description |
|-----------|----------|-----------------------------------------------------------------------------|
| pdfPath | string | Absolute file path or file:// URI pointing to the PDF file on the device. |
Returns: A Promise that resolves to an array of absolute file paths — one JPEG image per PDF page, saved to the app's cache directory.
Throws if the file does not exist or cannot be opened.
Implementation Details
- iOS: Uses
PDFKitto render each page viaUIGraphicsImageRenderer. Images are saved as JPEG with 90% quality. - Android: Uses the built-in
android.graphics.pdf.PdfRenderer. Images are saved as JPEG with 90% quality. - Images are written to the OS cache directory and may be cleared by the system.
License
MIT
