{"_id":"@cherrystudio/pdf-to-img-napi","_rev":"5-ac92f9b97f9d8285c3d9c31a5c9ba756","name":"@cherrystudio/pdf-to-img-napi","dist-tags":{"latest":"0.0.2"},"versions":{"0.0.1":{"name":"@cherrystudio/pdf-to-img-napi","version":"0.0.1","keywords":["pdf","pdfjs","pdf-to-img-napi","pdf-to-png","vitest","jest"],"author":{"name":"DeJeune"},"license":"MIT","_id":"@cherrystudio/pdf-to-img-napi@0.0.1","maintainers":[{"name":"cherry.ai","email":"dev@cherry-ai.com"},{"name":"dejeune","email":"sy20010504@gmail.com"},{"name":"eeee_007","email":"chentao020717Private@outlook.com"}],"homepage":"https://github.com/DeJeune/pdf-to-img-rs#readme","bugs":{"url":"https://github.com/DeJeune/pdf-to-img-rs/issues"},"bin":{"pdf2img":"bin/cli.mjs"},"dist":{"shasum":"c067e24db3e555bf6d8df1855da0b72c5d8a59f6","tarball":"https://registry.npmjs.org/@cherrystudio/pdf-to-img-napi/-/pdf-to-img-napi-0.0.1.tgz","fileCount":10,"integrity":"sha512-DUCDTjvpSrObZDT//XwL5EeDy/y1mGgQckIFh/dJERHkMYk8HgOXvfLVZbvFliMe/Jkf+jJI9FQr7wpWtSaCvQ==","signatures":[{"sig":"MEUCIC6xZrNIImdO9cVTBv5tli5dsT203+rQortONkn2y3QAAiEA1qIJzvgCkIaWvqD/iGVC6ccEu1kzBuMfG21JHx/rMuw=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":15552},"type":"module","types":"dist/index.d.ts","engines":{"node":">=18"},"exports":"./dist/index.js","gitHead":"bf710d7a6150f7d80d83eaa6d1f0e0533b6266de","scripts":{"lint":"eslint .","test":"vitest --pool=forks","build":"tsc && rm -rf dist && mv temp/src dist && rm -rf temp","trypublish":"npm publish --provenance || true"},"_npmUser":{"name":"dejeune","email":"sy20010504@gmail.com"},"prettier":{"trailingComma":"es5"},"repository":{"url":"git+https://github.com/DeJeune/pdf-to-img-rs.git","type":"git"},"_npmVersion":"10.9.0","description":"📃📸 Converts PDFs to images in nodejs with napi-rs/canvas","directories":{},"_nodeVersion":"23.1.0","dependencies":{"pdfjs-dist":"^4.10.38","@napi-rs/canvas":"^0.1.71"},"engineStrict":true,"_hasShrinkwrap":false,"devDependencies":{"jsdom":"^26.0.0","eslint":"^9.20.1","vitest":"^1.6.0","typescript":"^5.2.2","@types/node":"^22.13.4","eslint-config-kyle":"^25.0.0","@vitest/coverage-v8":"^1.6.0","jest-image-snapshot":"^6.4.0","@types/jest-image-snapshot":"^6.4.0"},"_npmOperationalInternal":{"tmp":"tmp/pdf-to-img-napi_0.0.1_1749991971585_0.8620318833039096","host":"s3://npm-registry-packages-npm-production"}},"0.0.2":{"name":"@cherrystudio/pdf-to-img-napi","version":"0.0.2","keywords":["pdf","pdfjs","pdf-to-img-napi","pdf-to-png","vitest","jest"],"author":{"name":"DeJeune"},"license":"MIT","_id":"@cherrystudio/pdf-to-img-napi@0.0.2","maintainers":[{"name":"cherry.ai","email":"dev@cherry-ai.com"},{"name":"dejeune","email":"sy20010504@gmail.com"},{"name":"eeee_007","email":"chentao020717Private@outlook.com"}],"homepage":"https://github.com/DeJeune/pdf-to-img-rs#readme","bugs":{"url":"https://github.com/DeJeune/pdf-to-img-rs/issues"},"bin":{"pdf2img":"bin/cli.mjs"},"dist":{"shasum":"04e3a433bbfe5bf9a90e0fe8035e5df14426872a","tarball":"https://registry.npmjs.org/@cherrystudio/pdf-to-img-napi/-/pdf-to-img-napi-0.0.2.tgz","fileCount":10,"integrity":"sha512-7TeLt+vVlPETj+aX+RtYCZ+LiKjU05BH+/kyseg5NJIQJlt5ISGhg9G/sWHYCtACHohdRqqams8VN8hbm6+Nhw==","signatures":[{"sig":"MEQCIDsBWKxXG7auXVS765+NXFWr+3iKaQORsu/aH+w+2ma4AiAKZnlHSGINEhb0+3+hG5DPSCfxNvuzfWbBnZrcfpMvnQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":15552},"type":"module","types":"dist/index.d.ts","engines":{"node":">=18"},"exports":"./dist/index.js","gitHead":"986e9ac3f1f63d8702e9b3fafd6a87f4f4f7eff1","scripts":{"lint":"eslint .","test":"vitest --pool=forks","build":"tsc && rm -rf dist && mv temp/src dist && rm -rf temp","trypublish":"npm publish --provenance || true"},"_npmUser":{"name":"dejeune","email":"sy20010504@gmail.com"},"prettier":{"trailingComma":"es5"},"repository":{"url":"git+https://github.com/DeJeune/pdf-to-img-rs.git","type":"git"},"_npmVersion":"10.9.0","description":"📃📸 Converts PDFs to images in nodejs with napi-rs/canvas","directories":{},"_nodeVersion":"23.1.0","dependencies":{"pdfjs-dist":"^4.10.38","@napi-rs/canvas":"^0.1.71"},"engineStrict":true,"_hasShrinkwrap":false,"devDependencies":{"jsdom":"^26.0.0","eslint":"^9.20.1","vitest":"^1.6.0","typescript":"^5.2.2","@types/node":"^22.13.4","eslint-config-kyle":"^25.0.0","@vitest/coverage-v8":"^1.6.0","jest-image-snapshot":"^6.4.0","@types/jest-image-snapshot":"^6.4.0"},"_npmOperationalInternal":{"tmp":"tmp/pdf-to-img-napi_0.0.2_1749994610524_0.9664826178384545","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2025-06-15T12:52:51.528Z","modified":"2025-11-11T03:58:23.373Z","0.0.1":"2025-06-15T12:52:51.776Z","0.0.2":"2025-06-15T13:36:50.727Z"},"bugs":{"url":"https://github.com/DeJeune/pdf-to-img-rs/issues"},"author":{"name":"DeJeune"},"license":"MIT","homepage":"https://github.com/DeJeune/pdf-to-img-rs#readme","keywords":["pdf","pdfjs","pdf-to-img-napi","pdf-to-png","vitest","jest"],"repository":{"url":"git+https://github.com/DeJeune/pdf-to-img-rs.git","type":"git"},"description":"📃📸 Converts PDFs to images in nodejs with napi-rs/canvas","maintainers":[{"email":"verc20.dev@proton.me","name":"defi-failure"},{"email":"dev@cherry-ai.com","name":"cherry.ai"},{"email":"sy20010504@gmail.com","name":"dejeune"},{"email":"chentao020717Private@outlook.com","name":"eeee_007"},{"email":"daoquqiexing@gmail.com","name":"whatprototype"},{"email":"eurfelux@gmail.com","name":"eurfelux"}],"readme":"# pdf-to-img\n\n[![Build Status](https://github.com/k-yle/pdf-to-img/workflows/Build%20and%20Test/badge.svg)](https://github.com/k-yle/pdf-to-img/actions)\n[![Coverage Status](https://coveralls.io/repos/github/k-yle/pdf-to-img/badge.svg?branch=main&t=LQmPNl)](https://coveralls.io/github/k-yle/pdf-to-img?branch=main)\n[![npm version](https://badge.fury.io/js/pdf-to-img.svg)](https://badge.fury.io/js/pdf-to-img)\n[![npm](https://img.shields.io/npm/dt/pdf-to-img.svg)](https://www.npmjs.com/package/pdf-to-img)\n![npm bundle size](https://img.shields.io/bundlephobia/minzip/pdf-to-img)\n\n📃📸 Converts PDFs to images in nodejs.\n\nUseful for unit tests of PDFs\n\nSupports nodejs v18+, and comes with a CLI.\n\n## Install\n\n```sh\nnpm install -S pdf-to-img\n```\n\n> [!IMPORTANT]\n> You should use v4 by default. v4 requires nodejs v18 or later, and ESM modules.\n>\n> If you can't upgrade to v4 yet, you can still use v3. If you use v3, you can safely ignore `npm audit`'s [warning about pdfjs-dist](https://github.com/advisories/GHSA-wgrm-67xf-hhpq), since this library [disables `eval` by default](https://github.com/k-yle/pdf-to-img/commit/bdac3a1dcc2004c3f1fe7380bbb860086ec2746f).\n\n## Example\n\nNodeJS (using ESM Modules):\n\n```js\nimport { promises as fs } from \"node:fs\";\nimport { pdf } from \"pdf-to-img\";\n\nasync function main() {\n  let counter = 1;\n  const document = await pdf(\"example.pdf\", { scale: 3 });\n  for await (const image of document) {\n    await fs.writeFile(`page${counter}.png`, image);\n    counter++;\n  }\n\n\n  // you can also read a specific page number:\n  const page12buffer = await document.getPage(12)\n}\nmain();\n```\n\nIf your app does not support ESM modules, you can use v3 (see the warning above), or just change the import:\n\n```diff\n+ const { promises: fs } = require(\"node:fs\");\n- import { promises as fs } from \"node:fs\";\n- import { pdf } from \"pdf-to-img\";\n\n  async function main() {\n+   const { pdf } = await import(\"pdf-to-img\");\n    let counter = 1;\n    const document = await pdf(\"example.pdf\", { scale: 3 });\n    for await (const image of document) {\n      await fs.writeFile(`page${counter}.png`, image);\n      counter++;\n    }\n  }\n  main();\n```\n\nUsing jest (or vitest) with [jest-image-snapshot](https://npm.im/jest-image-snapshot):\n\n```js\nimport { pdf } from \"pdf-to-img\";\n\nit(\"generates a PDF\", async () => {\n  for await (const page of await pdf(\"example.pdf\")) {\n    expect(page).toMatchImageSnapshot();\n  }\n});\n\n// or if you want access to more details:\n\nit(\"generates a PDF with 2 pages\", async () => {\n  const doc = await pdf(\"example.pdf\");\n\n  expect(doc.length).toBe(2);\n  expect(doc.metadata).toEqual({ ... });\n\n  for await (const page of doc) {\n    expect(page).toMatchImageSnapshot();\n  }\n});\n\n```\n\nThe `pdf` function accepts either a path to the file on disk, or a data URL (e.g. `data:application/pdf;base64,...`)\n\n### Options\n\nYou can supply a second argument which is an object of options:\n\n```js\nconst doc = await pdf(\"example.pdf\", {\n  password: \"...\", // if the PDF is encrypted\n\n  scale: 2.0, // use this for PDFs with high resolution images if the generated image is low quality\n});\n```\n\n## CLI\n\n```sh\nnpm i -g pdf-to-img@latest\n\n# example:\npdf2img inputFile.pdf\n\n# options:\n# -s / --scale: set the scale (defaults to 3)\n# -p / --password: the password to unlock the PDF\n# -o / --output: the output folder, relative to the current working directory.\n# -g / --pages: set which pages to convert. eg: 1,4,7 (defaults to all pages)\n```\n","readmeFilename":"README.md"}