Skip to main content
Back to packages
5,212 GitHub stars

spatie/browsershot

View on GitHub

Description

Convert a webpage to an image or pdf using headless Chrome

The package can convert a web page to an image or PDF. The conversion is done behind the scenes by Puppeteer which runs a headless version of Google Chrome.

Here's a quick example:

use Spatie\Browsershot\Browsershot;
 
// an image will be saved
Browsershot::url('https://example.com')->save($pathToImage);

It will save a PDF if the path passed to the save method has a pdf extension.

// a pdf will be saved
Browsershot::url('https://example.com')->save('example.pdf');

You can also use an arbitrary html input, simply replace the url method with html:

Browsershot::html('<h1>Hello world!!</h1>')->save('example.pdf');

Recent Courses on Laravel Daily

Laravel 13 Starter Kit Teams and Customizations

10 lessons
33 min

Testing in Laravel 13 For Beginners

26 lessons
1 h 41 min read

How to Build Laravel 13 API From Scratch

30 lessons
1 h 23 min

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.