In my quest to master the usage of Puppeteer within a Vue.js application, I am facing a challenge. I am able to create a PDF based on the entire page successfully, but I am struggling to generate a PDF for a specific element on the page. Is there a method or class that I overlooked which can help with this task? I have searched for a chainable function within the 'page' object 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 came across the page.$(selector)
function, but I am unsure of how to properly chain it with a .then()
call to convert the returned HTML into a PDF.
Your insights and guidance on this matter would be greatly appreciated!