{"id":13465668,"url":"https://github.com/spatie/browsershot","last_synced_at":"2026-04-02T05:37:21.194Z","repository":{"id":16631380,"uuid":"19386515","full_name":"spatie/browsershot","owner":"spatie","description":"Convert HTML to an image, PDF or string","archived":false,"fork":false,"pushed_at":"2025-04-28T08:56:10.000Z","size":90366,"stargazers_count":5001,"open_issues_count":2,"forks_count":506,"subscribers_count":60,"default_branch":"main","last_synced_at":"2025-05-05T20:53:43.577Z","etag":null,"topics":["hacktoberfest","phantomjs","php","screenshot"],"latest_commit_sha":null,"homepage":"https://spatie.be/docs/browsershot","language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spatie.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":"docs/support-us.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"spatie"}},"created_at":"2014-05-02T19:42:11.000Z","updated_at":"2025-05-05T07:49:32.000Z","dependencies_parsed_at":"2023-02-16T06:35:15.099Z","dependency_job_id":"d5c9657c-c60d-45a6-a4ef-14ffb20f8e22","html_url":"https://github.com/spatie/browsershot","commit_stats":{"total_commits":479,"total_committers":137,"mean_commits":"3.4963503649635035","dds":0.4697286012526096,"last_synced_commit":"8454698101b78c78885bb712b37cd1da97ac8e2e"},"previous_names":[],"tags_count":162,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Fbrowsershot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Fbrowsershot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Fbrowsershot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Fbrowsershot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spatie","download_url":"https://codeload.github.com/spatie/browsershot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253929367,"owners_count":21985802,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","phantomjs","php","screenshot"],"created_at":"2024-07-31T15:00:33.581Z","updated_at":"2026-04-02T05:37:21.186Z","avatar_url":"https://github.com/spatie.png","language":"PHP","funding_links":["https://github.com/sponsors/spatie"],"categories":["PHP","Laravel","Table of Contents","类库"],"sub_categories":["PDF","PDF/条形码","Globalization"],"readme":"\u003cdiv align=\"left\"\u003e\n    \u003ca href=\"https://spatie.be/open-source?utm_source=github\u0026utm_medium=banner\u0026utm_campaign=browsershot\"\u003e\n      \u003cpicture\u003e\n        \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://spatie.be/packages/header/browsershot/html/dark.webp\"\u003e\n        \u003cimg alt=\"Logo for Browsershot\" src=\"https://spatie.be/packages/header/browsershot/html/light.webp\"\u003e\n      \u003c/picture\u003e\n    \u003c/a\u003e\n\n\u003ch1\u003eRender web pages to an image or PDF with Puppeteer\u003c/h1\u003e\n    \n[![Latest Version](https://img.shields.io/github/release/spatie/browsershot.svg?style=flat-square)](https://github.com/spatie/browsershot/releases)\n[![MIT Licensed](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)\n[![run-tests](https://img.shields.io/github/actions/workflow/status/spatie/browsershot/run-tests.yml?label=tests\u0026style=flat-square)](https://github.com/spatie/browsershot/actions)\n[![Total Downloads](https://img.shields.io/packagist/dt/spatie/browsershot.svg?style=flat-square)](https://packagist.org/packages/spatie/browsershot)\n    \n\u003c/div\u003e\n\nThe package can convert a web page to an image or PDF. The conversion is done behind the scenes by [Puppeteer](https://github.com/GoogleChrome/puppeteer) which runs a headless version of Google Chrome.\n\nHere's a quick example:\n\n```php\nuse Spatie\\Browsershot\\Browsershot;\n\n// an image will be saved\nBrowsershot::url('https://example.com')-\u003esave($pathToImage);\n```\n\nIt will save a PDF if the path passed to the `save` method has a `pdf` extension.\n\n```php\n// a pdf will be saved\nBrowsershot::url('https://example.com')-\u003esave('example.pdf');\n```\n\nYou can also use an arbitrary html input, simply replace the `url` method with `html`:\n\n```php\nBrowsershot::html('\u003ch1\u003eHello world!!\u003c/h1\u003e')-\u003esave('example.pdf');\n```\n\nIf your HTML input is already in a file locally use the :\n\n```php\nBrowsershot::htmlFromFilePath('/local/path/to/file.html')-\u003esave('example.pdf');\n```\n\nBrowsershot also can get the body of an html page after JavaScript has been executed:\n\n```php\nBrowsershot::url('https://example.com')-\u003ebodyHtml(); // returns the html of the body\n```\n\nIf you wish to retrieve an array list with all of the requests that the page triggered you can do so:\n\n```php\n$requests = Browsershot::url('https://example.com')\n    -\u003etriggeredRequests();\n\nforeach ($requests as $request) {\n    $url = $request['url']; //https://example.com/\n}\n```\n\nTo use Chrome's new [headless mode](https://developers.google.com/web/updates/2017/04/headless-chrome) pass the `newHeadless` method:\n\n```php\nBrowsershot::url('https://example.com')-\u003enewHeadless()-\u003esave($pathToImage);\n```\n\n## Support us\n\nLearn how to create a package like this one, by watching our premium video course:\n\n[![Laravel Package training](https://spatie.be/github/package-training.jpg)](https://laravelpackage.training)\n\nWe invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).\n\nWe 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](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).\n\n## Documentation\n\nAll documentation is available [on our documentation site](https://spatie.be/docs/browsershot).\n\n## Testing\n\nFor running the testsuite, you'll need to have Puppeteer installed. Pleaser refer to the Browsershot requirements [here](https://spatie.be/docs/browsershot/v4/requirements). Usually `npm -g i puppeteer` will do the trick.\n\nAdditionally, 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](https://github.com/spatie/pdf-to-text?tab=readme-ov-file#requirements). Usually `brew install poppler-utils` will suffice.\n\nFinally run the tests with:\n\n```bash\ncomposer test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.\n\n## Security\n\nIf you've found a bug regarding security please mail [security@spatie.be](mailto:security@spatie.be) instead of using the issue tracker.\n\n## Alternatives\n\nIf you're not able to install Node and Puppeteer, take a look at [v2 of browsershot](https://github.com/spatie/browsershot/tree/2.4.1), which uses Chrome headless CLI to take a screenshot. `v2` is not maintained anymore, but should work pretty well.\n\nIf using headless Chrome does not work for you take a look at at `v1` of this package which uses the abandoned `PhantomJS` binary.\n\n## Credits\n\n- [Freek Van der Herten](https://github.com/freekmurze)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Fbrowsershot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspatie%2Fbrowsershot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Fbrowsershot/lists"}