Home Arrow Icon Knowledge base Arrow Icon Global Arrow Icon Spatie/browsershot
    Browsershot PHP package convert webpage to image convert webpage to PDF headless Chrome Puppeteer web automation Spatie


Spatie/browsershot


Browsershot is a PHP package that allows you to convert a webpage to an image or PDF using headless Chrome[1][2]. It is built on top of the Puppeteer Node library[4].

Here are some key features of Browsershot:

- Convert a webpage to an image or PDF by providing a URL or HTML[1][2]
- Get the HTML body of a page after JavaScript has been executed[1][2]
- Retrieve an array of all requests triggered by a page[1][2]
- Customize the image format, size, and manipulation[3]
- Enable mobile emulation and device emulation[3]
- Dismiss dialogs, disable JavaScript and images, block URLs and domains[3]
- Wait for lazy-loaded resources, delayed screenshots, and JavaScript functions[3]
- Add custom JavaScript and CSS[3]
- Output directly to the browser[3]

To use Browsershot, you need to have Node 7.6.0 or higher installed along with Puppeteer[4]. On macOS, you can install Puppeteer via NPM[4]. On a Forge provisioned Ubuntu server, you can install the latest stable version of Chrome and then install Puppeteer[4].

Browsershot is an open-source package maintained by Spatie. It provides an easy-to-use API for converting webpages to images and PDFs using headless Chrome[1][2].

Citations:
[1] https://spatie.be/docs/browsershot/v4/introduction
[2] https://github.com/spatie/browsershot
[3] https://spatie.be/docs/browsershot/v4/usage/creating-images
[4] https://spatie.be/docs/browsershot/v4/requirements