npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pdftoimages

v1.1.1

Published

node.js wrapper for pdftocairo

Downloads

2

Readme

node-pdftocairo

Build Status Codecov npm MIT

Node.js wrapper for pdftocairo - PDF to PNG/JPEG/TIFF/PDF/PS/EPS/SVG using cairo
Inspired by jjwilly16/node-pdftk

A fork from node-pdftocairo Support stdOut as an option

Requirements

Since pdftocairo is included in Poppler, you should install Poppler before using this library.

Installation

yarn add node-pdftocairo
import { input } from 'node-pdftocairo';

API

Simple Usage

The first argument of input can be a file path or buffer.
If you pass a output file path to output, it will generate files and returns Promise<null>; otherwise return buffers without generating files.

Generate file buffer(s) from a PDF file

const inputPath = path.join(__dirname, '../test/files/sample.pdf');
const options = { format: 'png' };
const outputBuffer = await input(inputPath, options).output();

Generate file buffer(s) from the buffer

const inputPath = path.join(__dirname, '../test/files/sample.pdf');
const buffer = fs.readFileSync(inputPath);
const options = { format: 'png' };
const outputBuffer = await input(buffer, options).output();

Generate file(s) on the specified output path

const inputPath = path.join(__dirname, '../test/files/sample.pdf');
const outputPath = path.join(__dirname, '../test/files/sample-img');
const options = { format: 'png' };
await input(inputPath, options).output(outputPath);

Options

Reference: Ubuntu Manpage: pdftocairo

| Property | Description | Type | Default | |---|---|---|---| | bin | specify the path of pdftocairo | string | - | | format | output file format, should be one of png jpeg tiff ps eps pdf svg | string | - | | antialias | Set the cairo antialias option used for text and drawing in image files (or rasterized regions in vector output), should be one of default none gray subpixel fast good best | string | - | | range | Specifies the first/last page to convert. |{ f?: number, l?: number }| - | | filter | Generates only the odd or even numbered pages. | string | - | | singlefile | Writes only the first page and does not add digits. | boolean | false | | resolution | Specifies the X and Y resolution, in pixels per inch of image files (or rasterized regions in vector output). The default is 150 PPI. | number | { x: number, y: number } | - | | scale | Scales the long side of each page (width for landscape pages, height for portrait pages) to fit in scale-to pixels. The size of the short side will be determined by the aspect ratio of the page (PNG/JPEG/TIFF only). | number | { x: number, y: number } | - | | crop | Specifies the x-coordinate/y-coordinate of the crop area top left corner in pixels (image output) or points (vector output) and Specifies the width/height/size of crop area in pixels (image output) or points (vector output) (default is 0) | { x?: number, y?: number, W?: number, H?: number, sz?: number } | - | | cropbox | Uses the crop box rather than media box when generating the files (PNG/JPEG/TIFF only) | boolean | false | | mono | Generate a monochrome file (PNG and TIFF only). | boolean | false | | gray | Generate a grayscale file (PNG, JPEG, and TIFF only). | boolean | false | | transparent | Use a transparent page color instead of white (PNG and TIFF only). | boolean | false | | level2 | Generate Level 2 PostScript (PS only). | boolean | false | | level3 | Generate Level 3 PostScript (PS only). This enables all Level 2 features plus shading patterns and masked images. This is the default setting. | boolean | false | | originPageSizes | This option is the same as "-paper match". | boolean | false | | icc | Use the specified ICC file as the output profile (PNG only). The profile will be embedded in the PNG file. | string | - | | jpegopt | When used with -jpeg, takes a list of options to control the jpeg compression. See JPEG OPTIONS for the available options. | string | - | | paper | Set the paper size to one of "letter", "legal", "A4", or "A3" (PS,PDF,SVG only). This can also be set to "match", which will set the paper size of each page to match the size specified in the PDF file. If none the -paper, -paperw, or -paperh options are specified the default is to match the paper size. | string | { w: number, h: number }| - | | nocrop | By default, printing output is cropped to the CropBox specified in the PDF file. This option disables cropping (PS,PDF,SVG only). | boolean | false | | expand | Expand PDF pages smaller than the paper to fill the paper (PS,PDF,SVG only). By default, these pages are not scaled.| boolean | false | |noshrink| Don't scale PDF pages which are larger than the paper (PS,PDF,SVG only). By default, pages larger than the paper are shrunk to fit. | boolean | false | | nocenter | By default, PDF pages smaller than the paper (after any scaling) are centered on the paper. This option causes them to be aligned to the lower-left corner of the paper instead (PS,PDF,SVG only). | boolean | false | | duplex | Adds the %%IncludeFeature: *Duplex DuplexNoTumble DSC comment to the PostScript file (PS only). This tells the print manager to enable duplexing. | boolean | false | | ownerPassword | Specify the owner password for the PDF file. Providing this will bypass all security restrictions. | string | - | | userPassword | Specify the user password for the PDF file. | string | - | | stdOut | Using stdOut to capture output instead of temp files. | boolean | false |