2017 © Pedro Peláez
 

library browsershot

Convert a webpage to an image or pdf using headless Chrome

image

spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  • Thursday, July 12, 2018
  • by Spatie
  • Repository
  • 40 Watchers
  • 1422 Stars
  • 202,887 Installations
  • PHP
  • 10 Dependents
  • 0 Suggesters
  • 141 Forks
  • 9 Open issues
  • 70 Versions
  • 37 % Grown

The README.md

Logo for Browsershot

Render web pages to an image or PDF with Puppeteer

[![Latest Version](https://img.shields.io/github/release/spatie/browsershot.svg?style=flat-square)](https://github.com/spatie/browsershot/releases) [![MIT Licensed](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md) [![run-tests](https://img.shields.io/github/actions/workflow/status/spatie/browsershot/run-tests.yml?label=tests&style=flat-square)](https://github.com/spatie/browsershot/actions) [![Total Downloads](https://img.shields.io/packagist/dt/spatie/browsershot.svg?style=flat-square)](https://packagist.org/packages/spatie/browsershot)

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., (*1)

Here's a quick example:, (*2)

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., (*3)

// 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:, (*4)

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

If your HTML input is already in a file locally use the :, (*5)

Browsershot::htmlFromFilePath('/local/path/to/file.html')->save('example.pdf');

Browsershot also can get the body of an html page after JavaScript has been executed:, (*6)

Browsershot::url('https://example.com')->bodyHtml(); // returns the html of the body

If you wish to retrieve an array list with all of the requests that the page triggered you can do so:, (*7)

$requests = Browsershot::url('https://example.com')
    ->triggeredRequests();

foreach ($requests as $request) {
    $url = $request['url']; //https://example.com/
}

To use Chrome's new headless mode pass the newHeadless method:, (*8)

Browsershot::url('https://example.com')->newHeadless()->save($pathToImage);

Support us

Learn how to create a package like this one, by watching our premium video course:, (*9)

Laravel Package training, (*10)

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products., (*11)

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall., (*12)

Documentation

All documentation is available on our documentation site., (*13)

Testing

For running the testsuite, you'll need to have Puppeteer installed. Pleaser refer to the Browsershot requirements here. Usually npm -g i puppeteer will do the trick., (*14)

Additionally, you'll need the pdftotext CLI which is part of the poppler-utils package. More info can be found in in the spatie/pdf-to-text readme. Usually brew install poppler-utils will suffice., (*15)

Finally run the tests with:, (*16)

composer test

Contributing

Please see CONTRIBUTING for details., (*17)

Security

If you've found a bug regarding security please mail security@spatie.be instead of using the issue tracker., (*18)

Alternatives

If you're not able to install Node and Puppeteer, take a look at v2 of browsershot, which uses Chrome headless CLI to take a screenshot. v2 is not maintained anymore, but should work pretty well., (*19)

If using headless Chrome does not work for you take a look at at v1 of this package which uses the abandoned PhantomJS binary., (*20)

Credits

License

The MIT License (MIT). Please see License File for more information., (*21)

The Versions

12/07 2018

dev-analysis-q1OKjv

dev-analysis-q1OKjv https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert screenshot chrome webpage headless puppeteer

12/07 2018

dev-master

9999999-dev https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel image pdf convert browser phantomjs screenshot chrome webpage headless puppeteer

12/07 2018

3.23.1

3.23.1.0 https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert screenshot chrome webpage headless puppeteer

12/07 2018

3.23.0

3.23.0.0 https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert screenshot chrome webpage headless puppeteer

20/04 2018

3.22.1

3.22.1.0 https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert screenshot chrome webpage headless puppeteer

18/04 2018

3.22.0

3.22.0.0 https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert screenshot chrome webpage headless puppeteer

12/04 2018

3.20.1

3.20.1.0 https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert screenshot chrome webpage headless puppeteer

12/04 2018

3.20.0

3.20.0.0 https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert screenshot chrome webpage headless puppeteer

03/04 2018

3.19.0

3.19.0.0 https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert screenshot chrome webpage headless puppeteer

28/03 2018

3.18.0

3.18.0.0 https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert screenshot chrome webpage headless puppeteer

22/02 2018

3.17.0

3.17.0.0 https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert screenshot chrome webpage headless puppeteer

08/02 2018

3.16.1

3.16.1.0 https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert screenshot chrome webpage headless puppeteer

28/01 2018

3.16.0

3.16.0.0 https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert screenshot chrome webpage headless puppeteer

20/01 2018

3.15.0

3.15.0.0 https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert screenshot chrome webpage headless puppeteer

24/12 2017

v2.x-dev

2.9999999.9999999.9999999-dev https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert browser screenshot chrome webpage headless

24/12 2017

2.4.2

2.4.2.0 https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert browser screenshot chrome webpage headless

24/12 2017

3.14.1

3.14.1.0 https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert screenshot chrome webpage headless puppeteer

10/12 2017

3.14.0

3.14.0.0 https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert screenshot chrome webpage headless puppeteer

07/12 2017

3.13.0

3.13.0.0 https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert screenshot chrome webpage headless puppeteer

20/11 2017

3.12.0

3.12.0.0 https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert screenshot chrome webpage headless puppeteer

18/11 2017

3.11.1

3.11.1.0 https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert screenshot chrome webpage headless puppeteer

16/11 2017

3.11.0

3.11.0.0 https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert screenshot chrome webpage headless puppeteer

13/11 2017

dev-analysis-Xa0Qem

dev-analysis-Xa0Qem https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert screenshot chrome webpage headless puppeteer

13/11 2017

3.10.0

3.10.0.0 https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert screenshot chrome webpage headless puppeteer

13/11 2017

3.9.0

3.9.0.0 https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert screenshot chrome webpage headless puppeteer

10/11 2017

3.8.1

3.8.1.0 https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert screenshot chrome webpage headless puppeteer

07/11 2017

3.8.0

3.8.0.0 https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert screenshot chrome webpage headless puppeteer

31/10 2017

3.7.0

3.7.0.0 https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert screenshot chrome webpage headless puppeteer

31/10 2017

3.6.0

3.6.0.0 https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert screenshot chrome webpage headless puppeteer

28/10 2017

3.5.0

3.5.0.0 https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert screenshot chrome webpage headless puppeteer

27/10 2017

3.4.0

3.4.0.0 https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert screenshot chrome webpage headless puppeteer

26/10 2017

3.3.1

3.3.1.0 https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert screenshot chrome webpage headless puppeteer

25/10 2017

3.3.0

3.3.0.0 https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert screenshot chrome webpage headless puppeteer

25/10 2017

3.2.1

3.2.1.0 https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert screenshot chrome webpage headless puppeteer

18/10 2017

3.2.0

3.2.0.0 https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert screenshot chrome webpage headless puppeteer

18/10 2017

3.1.0

3.1.0.0 https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert screenshot chrome webpage headless puppeteer

16/10 2017

3.0.0

3.0.0.0 https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert screenshot chrome webpage headless puppeteer

27/09 2017

2.4.1

2.4.1.0 https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert browser screenshot chrome webpage headless

21/09 2017

2.4.0

2.4.0.0 https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert browser screenshot chrome webpage headless

19/09 2017

2.3.0

2.3.0.0 https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert browser screenshot chrome webpage headless

31/08 2017

2.2.0

2.2.0.0 https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert browser screenshot chrome webpage headless

06/08 2017

2.1.0

2.1.0.0 https://github.com/spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

image pdf convert browser screenshot chrome webpage headless

05/07 2017

2.0.3

2.0.3.0 https://github.com/spatie/browsershot

Convert a webpage to an image using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel image convert browser phantomjs screenshot webpage

05/07 2017

2.0.2

2.0.2.0 https://github.com/spatie/browsershot

Convert a webpage to an image using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel image convert browser phantomjs screenshot webpage

04/07 2017

2.0.1

2.0.1.0 https://github.com/spatie/browsershot

Convert a webpage to an image using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel image convert browser phantomjs screenshot webpage

03/07 2017

2.0.0

2.0.0.0 https://github.com/spatie/browsershot

Convert a webpage to an image using headless Chrome

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel image convert browser phantomjs screenshot webpage

02/06 2017

1.9.1

1.9.1.0 https://github.com/spatie/browsershot

Convert a webpage to an image

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel image convert browser phantomjs screenshot webpage

13/05 2017

1.9.0

1.9.0.0 https://github.com/spatie/browsershot

Convert a webpage to an image

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel image convert browser phantomjs screenshot webpage

28/04 2017

1.8.0

1.8.0.0 https://github.com/spatie/browsershot

Convert a webpage to an image

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel image convert browser phantomjs screenshot webpage

14/03 2017

1.7.0

1.7.0.0 https://github.com/spatie/browsershot

Convert a webpage to an image

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel image convert browser phantomjs screenshot webpage

02/02 2017

1.6.0

1.6.0.0 https://github.com/spatie/browsershot

Convert a webpage to an image

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel image convert browser phantomjs screenshot webpage

28/12 2016

1.5.4

1.5.4.0 https://github.com/spatie/browsershot

Convert a webpage to an image

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel image convert browser phantomjs screenshot webpage

12/11 2016

1.5.3

1.5.3.0 https://github.com/spatie/browsershot

Convert a webpage to an image

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel image convert browser phantomjs screenshot webpage

18/08 2016

1.5.2

1.5.2.0 https://github.com/spatie/browsershot

Convert a webpage to an image

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel image convert browser phantomjs screenshot webpage

18/08 2016

dev-analysis-zd1WmL

dev-analysis-zd1WmL https://github.com/spatie/browsershot

Convert a webpage to an image

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel image convert browser phantomjs screenshot webpage

25/04 2016

1.5.1

1.5.1.0 https://github.com/spatie/browsershot

Convert a webpage to an image

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel image convert browser phantomjs screenshot webpage

11/03 2016

1.5.0

1.5.0.0 https://github.com/spatie/browsershot

Convert a webpage to an image

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel image convert browser phantomjs screenshot webpage

23/11 2015

1.4.0

1.4.0.0 https://github.com/spatie/browsershot

Convert a webpage to an image

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel image convert browser phantomjs screenshot webpage

13/11 2015

1.3.0

1.3.0.0 https://github.com/spatie/browsershot

Convert a webpage to an image

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel image convert browser phantomjs screenshot webpage

23/08 2015

1.2.4

1.2.4.0 https://github.com/spatie/browsershot

Convert a webpage to an image

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel image convert browser phantomjs screenshot webpage

25/05 2015

1.2.3

1.2.3.0 https://github.com/spatie/browsershot

Convert a webpage to an image

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel image convert browser phantomjs screenshot webpage

22/05 2015

1.2.2

1.2.2.0 https://github.com/spatie/browsershot

Convert a webpage to an image

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel image convert browser phantomjs screenshot webpage

13/05 2015

1.2.1

1.2.1.0

Convert a webpage to an image

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel image convert browser phantomjs screenshot webpage

11/05 2015

1.2.0

1.2.0.0

Convert a webpage to an image

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel image convert browser phantomjs screenshot webpage

03/02 2015

1.1.0

1.1.0.0

Convert a webpage to an image

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel image convert browser phantomjs screenshot webpage

16/01 2015

1.0.0

1.0.0.0

Convert a webpage to an image

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel image convert browser phantomjs screenshot webpage

29/12 2014

0.1.3

0.1.3.0

Convert a webpage to an image

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel image convert browser phantomjs screenshot webpage

22/06 2014

0.1.2

0.1.2.0

Convert a webpage to an image

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel image convert browser phantomjs screenshot webpage

03/05 2014

0.1.1

0.1.1.0

Convert a webpage to an image

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel image convert browser phantomjs screenshot webpage

02/05 2014

0.1.0

0.1.0.0

Convert a webpage to an image

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel image convert browser phantomjs screenshot webpage