I'm familiarizing myself with Puppeteer to use in a Vue.js app but I can't figure out how to generate a PDF based on specific element on the page. I can successfully create a PDF based on the full page, but that's not ideal. Is there a method or class I missed that can allow this? I couldn't find a chainable page
function to filter by selector(s) like so:
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://what.a.fancy/website', {waitUntil: 'networkidle2'});
await page.$('.just-this-html').pdf(options);
I did see there's a page.$(selector)
function but I'm not sure how to chain that with a .then()
call that could access the returned HTML to a PDF.
Thanks!
setContent
call is made. – Gyration