Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
[WIP] Puppeteer backend #285
This isn't much tested yet, more a proof-of-concept.
(Chrome is installed by Puppeteer by default, but needs to be executable. There also is an option to use your own Chrome, but could be out sync)
require __DIR__ . '/../vendor/autoload.php'; $snappy = new \Knp\Snappy\Puppeteer\Pdf(); $result = $snappy->getOutput('http://www.github.com', ['format' => 'a6']); header('Content-Type: application/pdf'); header('Content-Disposition: inline; filename="file.pdf"'); echo $result; $snappy->generate('http://www.github.com', 'github.pdf', , true); $snappy->generateFromHtml('<h1>Bill</h1><p>You owe me money, dude.</p>', '/test.pdf');
Not all options are configured/tested yet, but should provide some more options then the CLI.
Only thing I saw is that all HTML is now passed through the commandline? Not sure if that has limitations. Also the chrome generator added
The script is based on https://github.com/spatie/browsershot/tree/v3 but extended for more options and modified for Node6
To be fair, this does seem to be slower . Not tested with large ones, but wkhtmltopdf + chrome cli are 300 ms for just the