vladocar/screenshoteer

Bug: Using `--el` and `--pdf` results in full page pdf generated

stephanschubert opened this issue · 5 comments

I ran:

screenshoteer --url  https://news.ycombinator.com/item\?id\=18598672 --el ".fatitem" --pdf

Thanks! I will fix this in the next version.

I tried but for some reason puppeteer doesn't handle pdf as screenshot.

@vladocar Hmm, have you tried setting the page dimensions and using some custom CSS to hide the non-selected elements?

page.pdf() generates a pdf of the page with print css media. To generate a pdf with screen media, call page.emulateMedia('screen') before calling page.pdf():

As you can see from the

await page.emulateMedia('screen');

the pdf is already using page.emulateMedia('screen').

The problem is when const el = await page.$("#main");
el.screenshot(...) works without problem
el.pdf(..) doesn't work.

However I'm sure there is a solution, I simply don't have a time to try everything.

But you are more then welcome to try. If you find a solution please let me know :)

Ah sorry, I didn't check. Understood.. I will let you know if I figure sth out.