react-native-pdf-cover v0.1.5
react-native-pdf-cover
High-performance PDF cover image extraction using native PDF rendering engines:
- Android: Uses
PdfRenderer
from Android Framework - iOS: Uses
PDFKit
from Apple's native framework
API documentation
Methods
getPDFCover(params)
Gets a cover image from a specific page of a PDF file.
Parameters
params
(Object)source
(ImageURISource): The source of the PDF file. Can be a URI (remote URL, local file path, or base64 string)password
(string, optional): Password if the PDF is encryptedpage
(number, optional): Page number to get the cover from (default: 1)size
(Object, optional): Desired size of the output imagewidth
(number): Width of the output imageheight
(number): Height of the output image
scale
(number, optional): Scale factor for the output image (default: 1)
Returns
Promise resolving to a PDFCoverItem object.
getPdfCoverList(params)
Gets cover images from all pages in a PDF file.
Parameters
params
(Object)source
(ImageURISource): The source of the PDF file. Can be a URI (remote URL, local file path, or base64 string)password
(string, optional): Password if the PDF is encryptedscale
(number, optional): Scale factor for the output images (default: 1)
Returns
Promise resolving to an array of PDFCoverItem objects.
Example
import { getPDFCover, getPdfCoverList } from 'react-native-pdf-cover';
// Get a single cover
const cover = await getPDFCover({
source: { uri: 'https://example.com/document.pdf' },
page: 1,
size: { width: 800, height: 600 },
scale: 2
});
// Get all covers
const covers = await getPdfCoverList({
source: { uri: 'https://example.com/document.pdf' },
scale: 1
});
Installation in managed Expo projects
For managed Expo projects, please follow the installation instructions in the API documentation for the latest stable release. If you follow the link and there is no documentation available then this library is not yet usable within managed projects — it is likely to be included in an upcoming Expo SDK release.
Installation in bare React Native projects
For bare React Native projects, you must ensure that you have installed and configured the expo
package before continuing.
Add the package to your npm dependencies
npm install react-native-pdf-cover react-native-blob-util --save
Configure for Android
Configure for iOS
Run npx pod-install
after installing the npm package.
Contributing
Contributions are very welcome! Please refer to guidelines described in the contributing guide.