You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
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
Working on converting a large app over to Chrome-PHP (this is wonderful!) from another library that didn't use Chrome and was clunky and slow. But anyway. Works great on most documents but when I get above a certain page count (50?) it stops working and I get the "Failed to load PDF Document" error in my window.
Been playing around with various settings and discovered that if I set Headless to False it sudden works great (biggest test was 200 pages). Unfortunately while I can run with headless set to false locally where I am developing, the server doesn't have a GUI so I can't run with headless set to false (throws errors about X11 missing, etc).
Any thoughts?
Here's my code (the $html var contains the rendered html of the page):
$browserFactory = new BrowserFactory(); // starts headless chrome $options = [ 'headless' => false, // disable headless mode 'landscape' => false, // default to false 'printBackground' => false, // default to false 'displayHeaderFooter' => false, // default to false 'preferCSSPageSize' => true, // default to false (reads parameters directly from @page) 'scale' => 1.0, // defaults to 1.0 (must be a float) ]; $browser = $browserFactory->createBrowser($options); try < // creates a new page and navigate to an URL $page = $browser->createPage(); $navigation = $page->setHtml($html); // print as pdf (in memory binaries) $pdf = $page->pdf(); // or directly output pdf without saving header('Content-Description: File Transfer'); header('Content-Type: application/pdf'); header('Content-Disposition: inline; filename=test2_'.date("His").'.pdf'); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); echo base64_decode($pdf->getBase64()); > finally < // bye $browser->close(); >
The text was updated successfully, but these errors were encountered: