Download the PHP package assisted-mindfulness/browsershot without Composer
On this page you can find all versions of the php package assisted-mindfulness/browsershot. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download assisted-mindfulness/browsershot
More information about assisted-mindfulness/browsershot
Files in assisted-mindfulness/browsershot
Package browsershot
Short Description Convert a webpage to an image or pdf using headless Chrome
License MIT
Homepage https://github.com/spatie/browsershot
Informations about the package browsershot
Browsershot
The package can convert a webpage to an image or PDF. The conversion is done behind the screens by Google Chrome. This package has been tested on MacOS and Ubuntu. If you use another OS your mileage may vary. Chrome should be installed on your system.
On a Forge provisioned Ubuntu server you can install the latest stable version of Chrome like this:
Also, if necessary, you need to install additional resources, such as fonts for displaying emoji:
Installation
This package can be installed through Composer.
Usage
In all examples it is assumed that you imported this namespace at the top of your file
Here's the easiest way to create an image of a webpage:
Browsershot will make an educated guess where Google Chrome is located. If Chrome can not be found on your system you can manually set its location:
By default the screenshot will be a png
and it's size will match the resolution you use for your desktop. Want another size of screenshot? No problem!
You can also set the size of the output image independently of the size of window. Here's how to resize a screenshot take with a resolution of 1920x1080 and scale that down to something that fits inside 200x200.
You can also capture the webpage at higher pixel densities by passing a device scale factor value of 2 or 3. This mimics how the webpage would be displayed on a retina/xhdpi display.
In fact, you can use all the methods spatie/image provides. Here's an example where we create a greyscale image:
If, for some reason, you want to set the user agent Google Chrome should use when taking the screenshot you can do so:
The default timeout of Browsershot is set to 60 seconds. Of course, you can modify this timeout:
Browsershot will save a pdf if the path passed to the save
method has a pdf
extension.
Alternatively you can explicitly use the savePdf
method:
Browsershot also can get the body of an html page after JavaScript has been executed:
You can also use an arbitrary html input, simply replace the url
method with html
:
License
The MIT License (MIT). Please see License File for more information.
This is a fork of the spatie/browsershot project which does not require Node and Puppeteer to be installed on your web server.
All versions of browsershot with dependencies
spatie/image Version ^2.2
spatie/phpunit-snapshot-assertions Version ^4.0
spatie/temporary-directory Version ^2.1
symfony/process Version ^6.0