@pixdif/pdf-parser
TypeScript icon, indicating that this package has built-in type declarations

0.10.1 • Public • Published

Pixdif PDF Parser

Build Status Npm Package

A PDF parser for pixdif to read PDF files and render each page into an image (PNG format), inspired by pdf.js and node-canvas.

You can install it as a pixdif plugin, or just use it to convert PDF files into images so that any other frameworks can compare or consume them, such as Playwright, WebDriver.IO or Allure Report.

License

MIT

Installation

npm install @pixdif/pdf-parser

Example

import { finished } from 'stream/promises';

const parser = new PdfParser('test/sample/shape.pdf');
await parser.open();

const pageNum = await parser.getPageNum();

for (let i = 0; i < pageNum; i++) {
	const page = await parser.getPage(0);
	console.log(page.getTitle());
	const output = fs.createWriteStream(`output/Page ${i + 1} - ${page.getTitle()}.png`);
	const image = await page.render();
	image.pipe(output);
	await finished(output);
}

await parser.close();

/@pixdif/pdf-parser/

    Package Sidebar

    Install

    npm i @pixdif/pdf-parser

    Weekly Downloads

    25

    Version

    0.10.1

    License

    MIT

    Unpacked Size

    8.77 kB

    Total Files

    13

    Last publish

    Collaborators

    • takashiro