Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PDF fullPage support #897

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add PDF fullPage support #897

wants to merge 1 commit into from

Conversation

Tarpsvo
Copy link

@Tarpsvo Tarpsvo commented Oct 23, 2024

The fullPage option does not work by default when creating a PDF. This change will force the command to manually evaluate the width and height of the page before creating the PDF. It has its flaws (when document.body is not the scrollable element for example), but it will cover 99% of the cases.

Let me know if it requires changing in any way or if you're not interested at all in this.

@AlexVanderbist
Copy link
Member

Hey, isn't this fixed on a later Puppeteer version? I'm on v23.0 and this seems to work as is. I might be missing something tho

@Tarpsvo
Copy link
Author

Tarpsvo commented Nov 25, 2024

Interesting... I am also on Puppeteer version 23.4.1 and it couldn't save the PDF as a single page for me, only screenshots. I'm running it on Mac locally (Node 18) and Linux (Node 20) on the server. Both displayed the same issue. Any ideas what variables am I missing here I could test?

This is currently my whole command:

Browsershot::url($targetPageUrl)
    ->setIncludePath('$PATH:/usr/local/bin:/opt/homebrew/bin:/usr/bin')
    ->showBackground()
    ->margins(0, 0, 0, 0)
    ->windowSize(1180, 0)
    ->fullPage()
    ->pages(1)
    ->pdf();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants