webpage-to-pdf
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

webpage-to-pdf

how to use

Mac

import WebpageToPdf from 'webpage-to-pdf';

(async () => {
    const wtp = new WebpageToPdf();
    await wtp.init({
        parallelRequests:3,
        shareCookies: true
    });
    wtp.convertPageToPdf('https://www.google.com');
    wtp.convertPageToPdf('https://github.com/bhups-83/webpage-to-pdf/blob/main/README.md',
        {
            'referer': 'https://github.com'
        }
    );
    await wtp.saveAllPagesToPdf("./output.pdf");
})();

Windows

On windows, there is a bug with shipped chrome. Current workaround is to pass --no-sandbox args to the underlying puppeteer library, which in turn passes it to chrome.

import WebpageToPdf from 'webpage-to-pdf';
(async () => {
    const wtp = new WebpageToPdf();
    await wtp.init({
        parallelRequests:1,
        options: {
            headless: true,
            timeout: 0,
            args: ["--no-sandbox"],
    }});
    wtp.convertPageToPdf('https://www.google.com');
    wtp.convertPageToPdf('https://www.google.com');
    await wtp.saveAllPagesToPdf("./output.pdf");
})();

Package Sidebar

Install

npm i webpage-to-pdf

Weekly Downloads

10

Version

1.0.2

License

ISC

Unpacked Size

31 kB

Total Files

8

Last publish

Collaborators

  • 02aa165ae7