Skip to content

Why not use Puppeteer #28

@csga5000

Description

@csga5000

Hey Mixu, it seems like puppeteer would make this a lot simpler.

Something like this works for the same thing, and allows headers and footers. It uses puppeteer which is headless chrome developed by google.

Honestly, it seems superior, and more up to date. I wonder if you should just deprecate this package and recommend this in the readme.

const puppeteer = require('puppeteer');

(async() => {
	const browser = await puppeteer.launch();
	const page = await browser.newPage();
	await page.goto('file:///C:/dev/wkhtmltesting/page-full.html');
	await page.pdf({
		path: 'page-full-pupp.pdf',
		format: 'A4',
		displayHeaderFooter: true,
		headerTemplate: '<div></div>',
		footerTemplate: 
			'<div style="font-size: 12px; width: 100%; text-align: center; font-style: italic; padding-bottom: 0.5in; font-family: serif;">'+
				'Page <span class="pageNumber"></span>'+
			'</div>',
		margin: {
			top: '0.5in',
			bottom: '1.5in',
			left: '1in',
			right: '1in',
		}
	});

	await browser.close();
})();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions