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 🙏

© 2026 – Pkg Stats / Ryan Hefner

cpdfy

v0.0.4

Published

HTML to PDF converter with wkhtmltopdf native library. Run on both Win/Linux operating system.

Readme

cPDFY Logo

HTML to PDF converter with wkhtmltopdf native library. Run on both Win/Linux operating system. cPDFY is not a precompiled library. It will be compiled from source code in your machine. Before install cPDFY see node-gyp prerequisite from here

Windows prerequisite

npm install --global windows-build-tools

Linux OS prerequisite

Python v2.7, v3.5, v3.6, v3.7, or v3.8 sudo apt install make sudo apt install g++ sudo apt install libfontconfig1 libxrender1

How to install ?

npm install cpdfy --save

Required For Linux OS

In Linux OS make sure libwkhtmltox.so.0 file exists in /usr/lib/. If libwkhtmltox.so.0 not found in /usr/lib/, please copy it from /node_module/cpdfy/lib/**/libwkhtmltox.so.0 to /usr/lib/.

How to use it ?

/*import cPdfy instance*/
const { Cpdfy } = require('cpdfy');

Working with stream

01# This example create pdf from url

Cpdfy.createStream({ from_url: "https://wkhtmltopdf.org/" }, (err, stream) => {
    if (err) {
        console.log(err);
        return;
    }
    const fst = fs.createWriteStream(path.resolve(`./test_output/1_test_${Math.floor((0x999 + Math.random()) * 0x10000000)}.pdf`));
    stream.pipe(fst);
});

02# This example create pdf from html string

const html = fs.readFileSync('./test_output/test.html', { encoding: "utf-8" }).replace(/^\uFEFF/, '');
Cpdfy.createStream(html, (err, stream) => {
    if (err) {
        console.log(err);
        return;
    }
    const fst = fs.createWriteStream(path.resolve(`./test_output/2_test_${Math.floor((0x999 + Math.random()) * 0x10000000)}.pdf`));
    stream.pipe(fst);
});

03# This example create pdf from html string and write to fs.WriteStream

const file = fs.createWriteStream(path.resolve(`./test_output/3_test_${Math.floor((0x999 + Math.random()) * 0x10000000)}.pdf`));
Cpdfy.createStream(file, html, (err) => {
    if (err instanceof Error) {
        console.log(err);
    } else {
        console.log("Done...");
    }
});

04# This example create pdf from string with ICPdfConfig and write to WriteStream

const html = `
<!DOCTYPE html>
    <html lang="es">
    <head>
        <title>Test PDF</title>
    </head>
    <body>
        <h1 style="color:red;">Hello World....</h1>
    </body>
</html>
`;
const file4 = fs.createWriteStream(path.resolve(`./test_output/4_test_${Math.floor((0x999 + Math.random()) * 0x10000000)}.pdf`));
Cpdfy.createStream(file4, {
    global_settings: {
        documentTitle: "This is printed copy",
        orientation: "Landscape",
        size: {
            paperSize: "Legal"
        },
        margin: {
            top: "1.27cm",
            bottom: "1.27cm",
            left: "1.27cm",
            right: "1.27cm",
        }
    }
}, html);

05# This example create pdf from url and write to ServerResponse

controller.get('/pdf-test', (ctx, match) => {
    const url = help.mayBeString(ctx.req.query["url"]);
    if (!url) {
        return ctx.res.status(200).type("text").send("Invalid request...");
    }
    ctx.res.status(200).noCache();
    Cpdfy.createStream(ctx.res, { from_url: decodeURIComponent(url) }, (err) => err && ctx.handleError(err, () => { }));
});

06# This example create pdf from url and write to ServerResponse with callback

controller.get('/pdf', (ctx, match) => {
    const url = help.mayBeString(ctx.req.query["url"]);
    if (!url) {
        return ctx.res.status(200).type("text").send("Invalid request...");
    }
    Cpdfy.createStream({ from_url: decodeURIComponent(url) }, (err, stream) => {
        ctx.handleError(err, () => {
            Cpdfy.setHeader(ctx.res);
            ctx.res.status(200).noCache().type("pdf");
            stream.pipe(ctx.res);
        });
    });
});

07# This example create pdf from url and write to ouput path

Cpdfy.generatePdf({ from_url: "https://wkhtmltopdf.org/", out_path: path.resolve('./from_url.pdf') });

08# This example create pdf from url and return Buffer

Cpdfy.generatePdf({ from_url: "https://wkhtmltopdf.org/" });

Note: This version supports win32/win64/linux64