If you want to use pdfjs2png as command, install with -g
option.
npm i -g pdfjs2png
Or if you want to use pdfjs2png as npm package in your Node.js project, just install.
npm i pdfjs2png
You can use pdfjs2png
command if you have install with -g
option.
The following command:
pdfjs2png test/helloworld.pdf
will output tmp file path of converted images to stdout:
/tmp/helloworld_pdf_page_1.png
pdfjs2png
command supports multiple CLI arguments and stdin.
Try below commands:
echo test/helloworld.pdf test/20211026_news_gov_cloud_01.pdf | xargs pdfjs2png
cat test/helloworld.pdf | pdfjs2png -i
import path from "path";
import { promises as fs } from "fs";
import { pdfjs2png } from "pdfjs2png";
const fileName = path.basename(filepath);
const fileBuffer = await fs.readFile(filepath);
const results = await pdfjs2png(fileBuffer, fileName);
// results is an array of string of tmp file path of PDF pages.
console.log(results);
npm ci
npm run build
npm link
NODE_ENV=development pdfjs2png test/helloworld.pdf