webpage-to-pdf
v1.0.2
Published
Utility to export multiple webpages into single PDF
Downloads
19
Maintainers
Readme
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");
})();