pdfjs2png
v0.0.1
Published
Simple CLI tool convert PDF file into png image with pdf.js and node-canvas
Readme
pdfjs2png - Simple CLI tool convert PDF file into png images with pdf.js and node-canvas
Install
If you want to use pdfjs2png as command, install with -g option.
npm i -g pdfjs2pngOr if you want to use pdfjs2png as npm package in your Node.js project, just install.
npm i pdfjs2pngBasic Usage as command
You can use pdfjs2png command if you have install with -g option.
The following command:
pdfjs2png test/helloworld.pdfwill output tmp file path of converted images to stdout:
/tmp/helloworld_pdf_page_1.pngAdvanced usage
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 -iBasic Usage as package
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);Development
npm ci
npm run build
npm link
NODE_ENV=development pdfjs2png test/helloworld.pdf