Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Use Spatie Browsershot to turn a trusted HTML string into a PDF with Browsershot::html($html)->savePdf($path). Browsershot renders through a browser, so its runtime needs compatible Node.js, Puppeteer, and Chrome or Chromium—and the HTML and any URL it receives must be validated. If you need a Blade-view workflow, Spatie Laravel PDF offers one, but its driver determines JavaScript support and deployment requirements.
Convert an HTML string to PDF with Browsershot
Install and configure Browsershot, then pass the HTML string to Browsershot::html() and save the result to an application-controlled path:
<?php
use SpatieBrowsershotBrowsershot;
$html = '<h1>Invoice</h1><p>Thank you for your order.</p>';
Browsershot::html($html)
->format('A4')
->savePdf(storage_path('app/example.pdf'));
The official Browsershot v4 API also accepts a URL for PDF rendering. Validate URLs before passing them to the browser process; do not accept arbitrary user-supplied URLs or markup without controls. The output path above uses Laravel’s storage directory, but choose a destination and access policy appropriate to your application. See Browsershot v4 PDF creation.
Install the runtime Browsershot needs
As documented for Browsershot v4, the requirements are Node.js 22.0 or higher and Puppeteer 23.0 or higher, along with a Chrome browser. Follow the package setup instructions to install Puppeteer and Chrome and, if automatic discovery fails, configure the executable paths for your environment. These are version-specific requirements: check the current documentation when setting up or upgrading.
Recommended Free Tools
#1 Best Overall
Having the PHP package installed alone is not sufficient. At runtime, the PHP process must be able to invoke Node and Puppeteer and reach the browser executable with the permissions and configuration your deployment provides. See Browsershot v4 requirements.
Set PDF layout options
Browsershot supports PDF controls including paper format or size, margins, headers and footers, and page selection. Add the options your document needs to the chain before saving; check the v4 PDF documentation for exact method names and supported values. For example, the core call above sets the paper format to A4. Do not assume a browser-generated PDF will match a different renderer pixel for pixel: layout depends on the browser, available fonts and assets, and the CSS being rendered.
Generate a PDF from a Blade view
If your source is a Laravel Blade template rather than an HTML string, Spatie Laravel PDF provides a view-based API. Its v2 documentation shows this pattern:
<?php
use SpatieLaravelPdfFacadesPdf;
Pdf::view('pdf.invoice', ['invoice' => $invoice])
->save(storage_path('app/invoice.pdf'));
Laravel PDF also supports rendering an HTML string. It is a separate abstraction with several drivers, not a guarantee that every renderer has the same requirements or behavior. Confirm which driver the application has configured before relying on JavaScript execution or a particular deployment setup. See Laravel PDF v2 PDF creation.
Choose a driver for CSS, JavaScript, and deployment
Pick a renderer based on the document and the infrastructure you can operate, not an assumed speed ranking. Spatie’s Laravel PDF v2 overview describes Browsershot, Gotenberg, Cloudflare, and Chrome as supporting modern CSS features; it describes WeasyPrint as strong for CSS Paged Media and DOMPDF as suitable for simpler layouts. Browser-based drivers execute JavaScript during PDF generation; DOMPDF does not.
| Driver or approach | What the documentation establishes | Consider it when |
|---|---|---|
| Browsershot | Browser-based rendering; the Laravel PDF Browsershot driver depends on the Browsershot package and its runtime requirements. | You need browser rendering and can provide the local Node/Puppeteer/browser setup. |
| Cloudflare | Uses the Browser Run API; does not require Node.js or a Chrome binary locally, but requires Cloudflare credentials and service access. | You prefer a hosted browser service and can use its credentials and service. |
| Gotenberg or Chrome | Listed among Laravel PDF drivers that support modern CSS features. The cited overview does not establish a full deployment comparison for these options. | Evaluate their documented setup against your infrastructure and rendering needs. |
| WeasyPrint | Described as strong for CSS Paged Media. | Your print layout depends on CSS Paged Media behavior. |
| DOMPDF | Described for simpler layouts; does not execute JavaScript. | Your document is straightforward and does not need JavaScript-driven rendering. |
The overview is not a benchmark, so it does not support performance rankings. Compare the CSS and JavaScript your template requires, whether local binaries or containers are acceptable, and whether a hosted service fits your access and credential policies. See Laravel PDF v2’s driver overview and installation and setup.
Rank #3
Validate inputs and control what the browser can access
Browsershot explicitly places responsibility for validating the HTML and URLs passed to it on the caller. Treat rendering as execution in a browser process, not as a harmless string-to-file operation.
- Build documents from controlled templates and validated application data. Avoid passing arbitrary user-provided HTML directly to the renderer.
- If rendering a URL, validate and restrict destinations according to your application’s needs. Do not let untrusted input choose arbitrary resources for the browser to request.
- Review which local files and network assets a template can access. Browser restrictions may block local resources; changes that relax browser security should be assessed carefully and limited to trusted inputs.
- Use application-controlled output paths and apply the access policy appropriate for potentially sensitive generated documents.
For customization and local-resource behavior, consult the Browsershot v4 PDF documentation and Laravel PDF v2 setup guidance.
Troubleshoot common rendering failures
Node, Puppeteer, or Chrome cannot be found
Check that the deployed environment meets the Browsershot v4 version requirements and that the PHP process can access the installed executables. If discovery does not work, configure the paths following the package setup instructions. A dependency available in an interactive shell may not be available to the web worker or queue process that creates the PDF.
Rank #4
Images, fonts, or styles are missing
Check that the browser can reach the asset URLs or local resources from the environment performing the render. Confirm that the URLs resolve there and that browser restrictions or deployment permissions are not preventing access. Avoid weakening browser security as a blanket fix, especially when any input is untrusted.
JavaScript-dependent content is absent
Use a browser-based driver if the PDF must include content created by JavaScript. Laravel PDF documents that DOMPDF does not execute JavaScript; selecting it for a JavaScript-dependent template will not provide browser execution.
The deployment cannot include a local browser runtime
Review the documented alternatives and their dependencies. In Laravel PDF, the Cloudflare driver avoids a local Node.js runtime and Chrome binary but requires Cloudflare credentials and service access. Other choices have their own setup and rendering trade-offs; consult the driver setup documentation rather than assuming they are interchangeable.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Best Value
Output differs across environments
Rendering depends on the actual PHP and Laravel application, Node, Puppeteer, browser, operating system, permissions, and container setup. The cited documentation does not provide a universal performance or cross-environment fidelity guarantee. Compare output in the deployment environment that will produce the PDFs.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Or skip the browser setup
For a website screenshot rather than a Laravel-rendered PDF, ScreenshotNeo offers a one-request screenshot API. It returns a PNG, JPEG, WebP, or PDF from a URL. See the ScreenshotNeo API documentation.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, failed loads, timeouts, and cache hits are not billed. Its MCP server lets AI agents use screenshot tools, and the free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. This captures a website URL—it is not a replacement for rendering your private Blade view or application-generated HTML. Learn about ScreenshotNeo.
Sign up for 1,000 free screenshots a month, no card required.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Frequently Asked Questions
Does Browsershot convert a string of HTML directly to PDF?
Yes. Its v4 documentation supports passing HTML to `Browsershot::html()` and saving the PDF with `savePdf()`.
Does the Browsershot approach work for a private Blade view?
The direct Browsershot call accepts HTML; for a Blade view, the documented Laravel PDF workflow uses `Pdf::view()` and the configured driver.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

