Gets a cover image from a specific page of a PDF file.
npm install react-native-pdf-coverHigh-performance PDF cover image extraction using native PDF rendering engines:
- Android: Uses PdfRenderer from Android Framework
- iOS: Uses PDFKit from Apple's native framework
- Documentation for the latest stable release
- Documentation for the main branch
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 encrypted
- page (number, optional): Page number to get the cover from (default: 1)
- size (Object, optional): Desired size of the output image
- width (number): Width of the output image
- height (number): Height of the output image
- scale (number, optional): Scale factor for the output image (default: 1)
#### Returns
Promise resolving to a PDFCoverItem object.
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 encrypted
- scale (number, optional): Scale factor for the output images (default: 1)
#### Returns
Promise resolving to an array of PDFCoverItem objects.
``javascript
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
});
`
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.
For bare React Native projects, you must ensure that you have installed and configured the expo package before continuing.
``
npm install react-native-pdf-cover react-native-blob-util --save
Run npx pod-install` after installing the npm package.
Contributions are very welcome! Please refer to guidelines described in the contributing guide.