Giter Site home page Giter Site logo

cretueusebiu / browsershot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from spatie/browsershot

0.0 0.0 0.0 88.14 MB

Convert HTML to an image, PDF or string

Home Page: https://spatie.be/docs/browsershot

License: MIT License

JavaScript 14.13% PHP 85.87%

browsershot's Introduction

Social Card of Spatie's Browsershot

Convert a webpage to an image or pdf using headless Chrome

Latest Version MIT Licensed run-tests Total Downloads

The package can convert a webpage to an image or pdf. The conversion is done behind the scenes by Puppeteer which controls 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');

If your HTML input is already in a file locally use the :

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:

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:

$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:

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:

Laravel Package training

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.

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.

Documentation

All documentation is available on our documentation site.

Contributing

Please see CONTRIBUTING for details.

Security

If you've found a bug regarding security please mail [email protected] instead of using the issue tracker.

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.

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

Credits

And a special thanks to Caneco for the logo โœจ

License

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

browsershot's People

Contributors

adrianmrn avatar alexvanderbist avatar bessone avatar brendt avatar carlcs avatar clementmas avatar darron1217 avatar dependabot[bot] avatar emanuelecoppola avatar freekmurze avatar github-actions[bot] avatar ioanschmitt avatar itsgoingd avatar jpoesen avatar laravel-shift avatar leonelvsc avatar mtawil avatar nielsvanpach avatar okaufmann avatar osbre avatar patinthehat avatar pharixces avatar rubenvanassche avatar rydurham avatar shadowalker89 avatar shahabphp avatar timvandijck avatar vitorsemeano avatar webaddicto avatar widgetsburritos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.