mixu / electroshot

Capture website screenshots with optional device and network emulation as jpg, png or pdf (with web fonts!) using Electron / Chrome.
548 stars 34 forks source link

Why not use Puppeteer #28

Open csga5000 opened 6 years ago

csga5000 commented 6 years ago

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();
})();
csga5000 commented 6 years ago

I'm open if you have arguments to why it's not better though!