https://github.com/yuiseki/pdfjs2png
Simple CLI tool and npm package convert PDF file into png images with pdf.js and node-canvas
https://github.com/yuiseki/pdfjs2png
cli nodejs npm npm-package pdf typescript
Last synced: 11 months ago
JSON representation
Simple CLI tool and npm package convert PDF file into png images with pdf.js and node-canvas
- Host: GitHub
- URL: https://github.com/yuiseki/pdfjs2png
- Owner: yuiseki
- License: wtfpl
- Created: 2022-01-10T05:43:31.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-07-29T21:02:37.000Z (12 months ago)
- Last Synced: 2025-07-29T23:48:14.218Z (12 months ago)
- Topics: cli, nodejs, npm, npm-package, pdf, typescript
- Language: TypeScript
- Homepage:
- Size: 269 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# pdfjs2png - Simple CLI tool and npm package 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.
```bash
npm i -g pdfjs2png
```
Or if you want to use pdfjs2png as npm package in your Node.js project, just install.
```bash
npm i pdfjs2png
```
## Basic Usage as command
You can use `pdfjs2png` command if you have install with `-g` option.
The following command:
```bash
pdfjs2png test/helloworld.pdf
```
will output tmp file path of converted images to stdout:
```bash
/tmp/helloworld_pdf_page_1.png
```
### Advanced usage
`pdfjs2png` command supports multiple CLI arguments and stdin.
Try below commands:
```bash
echo test/helloworld.pdf test/20211026_news_gov_cloud_01.pdf | xargs pdfjs2png
cat test/helloworld.pdf | pdfjs2png -i
```
## Basic Usage as package
```typescript
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
```bash
npm ci
npm run build
npm link
NODE_ENV=development pdfjs2png test/helloworld.pdf
```