Studiosity / grover

A Ruby gem to transform HTML into PDFs, PNGs or JPEGs using Google Puppeteer/Chromium
MIT License
914 stars 104 forks source link

Screenshot only a specific selector #208

Open brennop opened 10 months ago

brennop commented 10 months ago

Is it possible to screenshot only a specific element? It appears that puppeteer has that feature.

abrom commented 10 months ago

Not currently, but it would likely be pretty trivial to add support.. basically add a selector prop to the options.. when it's there, switch out the page for an element, then do the PDF/screenshot on that.

Do you want to have a go at adding the feature?

await page.waitForSelector(selector); const element = await
page.$(selector); await element.screenshot({ path: 'example.com.png', });

On Thu, 30 Nov 2023, 03:36 Brennim, @.***> wrote:

Is it possible to screenshot only a specific element? It appears that puppeteer has that feature.

— Reply to this email directly, view it on GitHub https://github.com/Studiosity/grover/issues/208, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA4WJ6EZBGPIMNB64FBB4JDYG5XDNAVCNFSM6AAAAAA773OABOVHI2DSMVQWIX3LMV43ASLTON2WKOZSGAYTOMBZG44DONQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

abrom commented 6 months ago

@brennop I didn't get any reply about this?