{"_id":"@dariyd/react-native-pdf-page-image","_rev":"3-7e496dac516fb3bf9c5f059c2b9460b5","name":"@dariyd/react-native-pdf-page-image","dist-tags":{"latest":"2.1.0"},"versions":{"1.0.1":{"name":"@dariyd/react-native-pdf-page-image","version":"1.0.1","keywords":["react-native","react native","pdf","pdf-to-image","pdf to image","pdf-thumbnail","pdf thumbnail","pdf-renderer","pdf renderer","pdfkit","pdf page","render pdf","image","thumbnail","turbomodules","turbo module","new-architecture","new architecture","fabric","codegen","ios","android","react-native-module","react-native-library"],"author":{"name":"Dariy D","email":"dariyd.soft@gmail.com"},"license":"MIT","_id":"@dariyd/react-native-pdf-page-image@1.0.1","maintainers":[{"name":"dariyd","email":"dariyd@gmail.com"}],"homepage":"https://github.com/dariyd/react-native-pdf-page-image#readme","bugs":{"url":"https://github.com/dariyd/react-native-pdf-page-image/issues"},"dist":{"shasum":"3cb3c44e77843eedd518cd1d97cb75f4d423f8c0","tarball":"https://registry.npmjs.org/@dariyd/react-native-pdf-page-image/-/react-native-pdf-page-image-1.0.1.tgz","fileCount":14,"integrity":"sha512-PO3/rsFZwOdT3/cci8RSkdK9qlTtOo7KCDEaz8VRyaUcnjO0Fdr4ZjbKoeWsLME5qjubd3cnIh+JgVZB3k+GAg==","signatures":[{"sig":"MEUCIH+86iBkWjqQlAl06S1pjy/wo/mVotXuX6KaDWagDvQjAiEAktk7QlkgPkWBk9LscQLforNF+J2M8BTwXGisTgnEW5Q=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":24846},"main":"index.js","title":"React Native PDF Page Image","types":"index.d.ts","source":"src/index","gitHead":"a34eac0b207ec8687f9f67747a58f191bc838242","scripts":{"test":"echo \"Error: no test specified\" && exit 1","prepare":"echo \"✅ Installing dependencies...\"","postpublish":"echo \"🎉 Published successfully! Don't forget to: git push && git push --tags\"","prepublishOnly":"echo \"📦 Preparing package for publishing...\" && npm pack --dry-run"},"_npmUser":{"name":"dariyd","email":"dariyd@gmail.com"},"repository":{"url":"git+https://github.com/dariyd/react-native-pdf-page-image.git","type":"git","baseUrl":"https://github.com/dariyd/react-native-pdf-page-image"},"_npmVersion":"10.9.3","description":"Render PDF pages to PNG images in React Native. Built for New Architecture (TurboModules + Codegen). Uses PDFKit on iOS and PdfRenderer on Android.","directories":{},"_nodeVersion":"22.19.0","react-native":"src/index","codegenConfig":{"name":"RNPdfPageImageSpec","type":"modules","android":{"javaPackageName":"com.pdfpageimage"},"jsSrcsDir":"src"},"_hasShrinkwrap":false,"devDependencies":{"react":"^19.0.0","react-native":"^0.83.1"},"licenseFilename":"LICENSE","peerDependencies":{"react":">=18.2.0","react-native":">=0.76.0"},"_npmOperationalInternal":{"tmp":"tmp/react-native-pdf-page-image_1.0.1_1775732461936_0.5772591065417265","host":"s3://npm-registry-packages-npm-production"}},"2.0.0":{"name":"@dariyd/react-native-pdf-page-image","version":"2.0.0","keywords":["react-native","react native","pdf","pdf-to-image","pdf to image","pdf-thumbnail","pdf thumbnail","pdf-renderer","pdf renderer","pdfkit","pdf page","render pdf","image","thumbnail","turbomodules","turbo module","new-architecture","new architecture","fabric","codegen","ios","android","react-native-module","react-native-library"],"author":{"name":"Dariy D","email":"dariyd.soft@gmail.com"},"license":"MIT","_id":"@dariyd/react-native-pdf-page-image@2.0.0","maintainers":[{"name":"dariyd","email":"dariyd@gmail.com"}],"homepage":"https://github.com/dariyd/react-native-pdf-page-image#readme","bugs":{"url":"https://github.com/dariyd/react-native-pdf-page-image/issues"},"dist":{"shasum":"3b7c93ed8461b545be8473eb1128a253478c00f1","tarball":"https://registry.npmjs.org/@dariyd/react-native-pdf-page-image/-/react-native-pdf-page-image-2.0.0.tgz","fileCount":14,"integrity":"sha512-QJAFvQZIoxJUvgJoeZLa81naU6GGukvp1VWV+pAt5UP0BAs08guCERgII6iCnZm7I2f2PTt/qUB1TQs7D8agFQ==","signatures":[{"sig":"MEQCIDciqXpYMEWadNVWZdot0BVUVd1J1JQnPf52Fa7xAQCfAiBsNq0AO/Oz9+FyRzxcCPKpxUwMNdbftIdYGKjcqOZpHw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":32977},"main":"index.js","title":"React Native PDF Page Image","types":"index.d.ts","source":"src/index","gitHead":"6b61553ef818c309640a4def950de968c8581fae","scripts":{"test":"echo \"Error: no test specified\" && exit 1","prepare":"echo \"✅ Installing dependencies...\"","postpublish":"echo \"🎉 Published successfully! Don't forget to: git push && git push --tags\"","prepublishOnly":"echo \"📦 Preparing package for publishing...\" && npm pack --dry-run"},"_npmUser":{"name":"dariyd","email":"dariyd@gmail.com"},"repository":{"url":"git+https://github.com/dariyd/react-native-pdf-page-image.git","type":"git","baseUrl":"https://github.com/dariyd/react-native-pdf-page-image"},"_npmVersion":"10.9.3","description":"Render PDF pages to JPEG or PNG images in React Native. Built for New Architecture (TurboModules + Codegen). Uses PDFKit on iOS and PdfRenderer on Android.","directories":{},"_nodeVersion":"22.19.0","react-native":"src/index","codegenConfig":{"name":"RNPdfPageImageSpec","type":"modules","android":{"javaPackageName":"com.pdfpageimage"},"jsSrcsDir":"src"},"_hasShrinkwrap":false,"devDependencies":{"react":"^19.0.0","react-native":"^0.83.1"},"licenseFilename":"LICENSE","peerDependencies":{"react":">=18.2.0","react-native":">=0.76.0"},"_npmOperationalInternal":{"tmp":"tmp/react-native-pdf-page-image_2.0.0_1784562114103_0.9992162691328417","host":"s3://npm-registry-packages-npm-production"}},"2.1.0":{"_id":"@dariyd/react-native-pdf-page-image@2.1.0","bugs":{"url":"https://github.com/dariyd/react-native-pdf-page-image/issues"},"dist":{"shasum":"6319f61c4ff51fbd41fc06f945179430841f06b1","tarball":"https://registry.npmjs.org/@dariyd/react-native-pdf-page-image/-/react-native-pdf-page-image-2.1.0.tgz","fileCount":14,"integrity":"sha512-wD5W4bVaLyam2qPaLn4IxPIBjK5IPbB5gRiwm3qCu+AUeKJRA2/NA1+At/XQfqv3xzLZTf09xYlyyKC50I4rTw==","signatures":[{"sig":"MEUCIGzNNQQPyc3xPIbdUELk7VwPDSvbVykIPFAbOEeU6FfOAiEA05KtceW4CKI88j4L42iKV9xd4CyEgyQoCD7HFf7d7i4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIHmBsJ5xLSXVZORTogmzmX0y4OJ9UvYcn0/0G5mDq4zQAiAwD4S4N6fBHK5i9PV/SJxJ/VGbYhmXTSPlzKTJ+gSVNA=="}],"unpackedSize":47488},"main":"index.js","name":"@dariyd/react-native-pdf-page-image","title":"React Native PDF Page Image","types":"index.d.ts","author":{"name":"Dariy D","email":"dariyd.soft@gmail.com"},"source":"src/index","gitHead":"93c21603fb9dbd68bdb258382251330fcb55d456","license":"MIT","scripts":{"test":"echo \"Error: no test specified\" && exit 1","prepare":"echo \"✅ Installing dependencies...\"","postpublish":"echo \"🎉 Published successfully! Don't forget to: git push && git push --tags\"","prepublishOnly":"echo \"📦 Preparing package for publishing...\" && npm pack --dry-run"},"version":"2.1.0","_npmUser":{"name":"dariyd","email":"dariyd@gmail.com"},"homepage":"https://github.com/dariyd/react-native-pdf-page-image#readme","keywords":["react-native","react native","pdf","pdf-to-image","pdf to image","pdf-thumbnail","pdf thumbnail","pdf-renderer","pdf renderer","pdfkit","pdf page","render pdf","image","thumbnail","turbomodules","turbo module","new-architecture","new architecture","fabric","codegen","ios","android","react-native-module","react-native-library"],"repository":{"url":"git+https://github.com/dariyd/react-native-pdf-page-image.git","type":"git","baseUrl":"https://github.com/dariyd/react-native-pdf-page-image"},"_npmVersion":"10.9.3","description":"Render PDF pages to JPEG or PNG images in React Native. Built for New Architecture (TurboModules + Codegen). Uses PDFKit on iOS and PdfRenderer on Android.","directories":{},"maintainers":[{"name":"dariyd","email":"dariyd@gmail.com"}],"_nodeVersion":"22.19.0","react-native":"src/index","codegenConfig":{"name":"RNPdfPageImageSpec","type":"modules","android":{"javaPackageName":"com.pdfpageimage"},"jsSrcsDir":"src"},"_hasShrinkwrap":false,"devDependencies":{"react":"^19.0.0","react-native":"^0.83.1"},"licenseFilename":"LICENSE","peerDependencies":{"react":">=18.2.0","react-native":">=0.76.0"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/react-native-pdf-page-image_2.1.0_1790324324914_0.17540621434852266"}}},"time":{"created":"2026-04-09T11:01:01.774Z","modified":"2026-09-25T08:18:45.178Z","1.0.1":"2026-04-09T11:01:02.098Z","2.0.0":"2026-07-20T15:41:54.259Z","2.1.0":"2026-09-25T08:18:45.015Z"},"bugs":{"url":"https://github.com/dariyd/react-native-pdf-page-image/issues"},"author":{"name":"Dariy D","email":"dariyd.soft@gmail.com"},"license":"MIT","homepage":"https://github.com/dariyd/react-native-pdf-page-image#readme","keywords":["react-native","react native","pdf","pdf-to-image","pdf to image","pdf-thumbnail","pdf thumbnail","pdf-renderer","pdf renderer","pdfkit","pdf page","render pdf","image","thumbnail","turbomodules","turbo module","new-architecture","new architecture","fabric","codegen","ios","android","react-native-module","react-native-library"],"repository":{"url":"git+https://github.com/dariyd/react-native-pdf-page-image.git","type":"git","baseUrl":"https://github.com/dariyd/react-native-pdf-page-image"},"description":"Render PDF pages to JPEG or PNG images in React Native. Built for New Architecture (TurboModules + Codegen). Uses PDFKit on iOS and PdfRenderer on Android.","maintainers":[{"name":"dariyd","email":"dariyd@gmail.com"}],"readme":"# @dariyd/react-native-pdf-page-image\n\nRender PDF pages to JPEG or PNG images in React Native. Built for the **New Architecture** (TurboModules + Codegen).\n\n- **iOS**: PDFKit\n- **Android**: PdfRenderer\n\n## Installation\n\n```bash\nnpm install @dariyd/react-native-pdf-page-image\n# or\nyarn add @dariyd/react-native-pdf-page-image\n```\n\n### iOS\n\n```bash\ncd ios && pod install\n```\n\n### Android\n\nNo additional setup required — auto-linked via Gradle.\n\n## Requirements\n\n- React Native **0.76+** (New Architecture enabled)\n- iOS **15.0+**\n- Android API **24+**\n\n## What's new in 2.1\n\n- **`PdfPageImage.compress(uri, options?)`** — writes a smaller copy of a PDF with every page re-encoded as a JPEG (default 150 dpi, quality 70). Page sizes are kept; text becomes part of the page image. Works page by page on a background thread, so long scans don't spike memory. On Android the JPEGs are embedded directly (the system `PdfDocument` would store them uncompressed).\n\n```typescript\nconst result = await PdfPageImage.compress('file:///path/to/scan.pdf', { dpi: 150, quality: 70 });\nif (result.bytes < result.originalBytes * 0.8) {\n  // keep result.uri (a file:// in the temp/cache directory)\n}\n```\n\nBest for scans and photos. A PDF made of text (an emailed invoice) may come out larger — always compare `bytes` with `originalBytes`.\n\n## What changed in 2.0\n\n- **JPEG output by default** (`quality: 80`) — ~10–20× smaller than PNG for scanned/photographic pages. Pass `{ format: 'png' }` for the old behavior.\n- **iOS renders at true 1× scale.** Previously the output was silently multiplied by the device screen scale (3× on modern iPhones), so `scale: 1.0` produced 3× the pixels — and different sizes than Android. Now 1 PDF point = `scale` pixels on both platforms.\n- **New `maxDimension` option** — cap the long edge in pixels without knowing the page size. Ideal for thumbnails.\n- **iOS temp files moved** from the app's Documents directory to the temporary directory (no more user-visible litter if `close()` is missed).\n\n## API\n\n### `PdfPageImage.open(uri)`\n\nOpens a PDF and returns page count.\n\n```typescript\nconst info = await PdfPageImage.open('file:///path/to/document.pdf');\nconsole.log(info.pageCount); // 5\n```\n\n**Returns:** `Promise<{ uri: string, pageCount: number }>`\n\n### `PdfPageImage.generate(uri, page, scale?, options?)`\n\nRenders a single page to an image.\n\n```typescript\n// Full-quality render at 2x\nconst image = await PdfPageImage.generate('file:///path/to/document.pdf', 0, 2.0);\n\n// Lightweight thumbnail: long edge capped at 640 px\nconst thumb = await PdfPageImage.generate(pdfUri, 0, 1.0, { maxDimension: 640 });\nconsole.log(thumb.uri);    // file:///.../<uuid>.jpg\n```\n\n| Parameter | Type | Description |\n|-----------|------|-------------|\n| `uri` | `string` | PDF file URI |\n| `page` | `number` | Page index (0-based) |\n| `scale` | `number?` | Pixels per PDF point (default: `1.0`, range: `0.1` – `10.0`) |\n| `options` | `GenerateOptions?` | Output options (below) |\n\n**`GenerateOptions`:**\n\n| Option | Type | Description |\n|--------|------|-------------|\n| `format` | `'jpeg' \\| 'png'` | Output encoding (default: `'jpeg'`) |\n| `quality` | `number?` | JPEG quality 1–100 (default: `80`; ignored for PNG) |\n| `maxDimension` | `number?` | Cap the long edge in pixels; reduces the effective scale when needed (default: `0` = no cap) |\n\n**Returns:** `Promise<{ uri: string, width: number, height: number }>`\n\n### `PdfPageImage.generateAllPages(uri, scale?, options?)`\n\nRenders all pages to images. Same `options` as `generate`, applied per page.\n\n```typescript\nconst pages = await PdfPageImage.generateAllPages(pdfUri, 1.5, { quality: 90 });\npages.forEach((page, i) => {\n  console.log(`Page ${i}: ${page.uri} (${page.width}x${page.height})`);\n});\n```\n\n**Returns:** `Promise<Array<{ uri: string, width: number, height: number }>>`\n\n### `PdfPageImage.close(uri)`\n\nCloses the PDF and deletes temporary image files. Call this when you're done to free memory.\n\n```typescript\nawait PdfPageImage.close('file:///path/to/document.pdf');\n```\n\n**Returns:** `Promise<void>`\n\n## Supported URI formats\n\n| Format | Example |\n|--------|---------|\n| File path | `/path/to/file.pdf` |\n| File URI | `file:///path/to/file.pdf` |\n| HTTP/HTTPS | `https://example.com/doc.pdf` |\n| Base64 data URI | `data:application/pdf;base64,JVBERi0...` |\n| Content URI (Android) | `content://com.provider/doc.pdf` |\n\n## Example\n\n```typescript\nimport { PdfPageImage } from '@dariyd/react-native-pdf-page-image';\n\nasync function renderPdfThumbnails(pdfUri: string) {\n  try {\n    const { pageCount } = await PdfPageImage.open(pdfUri);\n    console.log(`PDF has ${pageCount} pages`);\n\n    // Render first page as a lightweight thumbnail\n    const thumbnail = await PdfPageImage.generate(pdfUri, 0, 1.0, {\n      maxDimension: 640,\n    });\n    // Use thumbnail.uri in an <Image /> component\n\n    // Or render all pages at full quality\n    const allPages = await PdfPageImage.generateAllPages(pdfUri, 2.0, {\n      quality: 90,\n    });\n\n    // Clean up when done\n    await PdfPageImage.close(pdfUri);\n  } catch (error) {\n    console.error('PDF rendering failed:', error);\n  }\n}\n```\n\n## Notes\n\n- Pages are cached per URI + page index + scale + options — repeated calls return cached results instantly\n- Temporary image files are stored in the temporary directory (iOS) or cache directory (Android)\n- Always call `close()` when done to free memory and delete temporary files\n- Pages are drawn on a white background, so JPEG (no alpha channel) loses nothing\n- Page rotation (90°, 180°, 270°) is handled automatically on iOS\n\n## License\n\nMIT\n","readmeFilename":"README.md"}