Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →To turn an HTML string into a PDF with Spatie Browsershot, pass it to Browsershot::html() and call savePdf(). Browsershot v4 requires Node.js 22.0 or higher and Puppeteer 23.0 or higher, plus an available Chrome browser. Validate HTML and URLs before rendering: a browser process should not receive arbitrary user input.
This guide covers direct Browsershot use and, separately, the Laravel PDF package’s Blade-view workflow. Their package generations and driver requirements differ.
As an Amazon Associate I earn from qualifying purchases.
Render an HTML string directly with Browsershot
Install and configure Spatie Browsershot v4 and its browser runtime first. Then render trusted HTML and save the PDF to an application-managed path:
<?php
use SpatieBrowsershotBrowsershot;
$html = '<!doctype html><html><body><h1>Invoice</h1><p>Paid</p></body></html>';
Browsershot::html($html)
->format('A4')
->savePdf(storage_path('app/example.pdf'));
The direct HTML-to-PDF call is documented by Spatie Browsershot v4. The example uses an A4 page; change the format and destination to suit your document and storage policy.
#1 Best Overall
Render a URL instead
Browsershot can also visit a URL and save the page as a PDF:
Browsershot::url($url)
->savePdf(storage_path('app/page.pdf'));
Only render URLs your application is allowed to access. Validate and constrain them before passing them to the browser.
Adjust the PDF output
Browsershot supports options including paper format or size, margins, headers and footers, and page selection. Use the documented options for the exact output you need rather than assuming browser print defaults will match your intended layout; see the PDF creation documentation.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Set up the Browsershot runtime
Browsershot v4 documents Node.js 22.0 or later and Puppeteer 23.0 or later as requirements. It also needs a Chrome browser. Follow the v4 setup instructions to install the dependencies and, when automatic discovery fails, configure the executable paths.
- Check the Node.js and Puppeteer versions against the v4 requirements.
- Confirm Chrome or Chromium is installed and accessible to the PHP process in the environment that generates PDFs.
- If a binary is installed outside the expected location, configure its path using Browsershot’s documented settings.
- Check process permissions and deployment or container configuration; local development success does not establish compatibility in another environment.
Generate a PDF from a Blade view
If you want Laravel-facing view rendering rather than calling Browsershot directly, Spatie Laravel PDF v2 documents rendering a Blade view with its facade:
<?php
use SpatieLaravelPdfFacadesPdf;
Pdf::view('pdf.invoice', ['invoice' => $invoice])
->save(storage_path('app/invoice.pdf'));
Laravel PDF v2 also supports an HTML string. Its PDF creation guide shows the view and HTML workflows. Confirm which driver is configured before relying on JavaScript execution or assuming a particular runtime.
Rank #3
Choose a driver for your layout and deployment
Laravel PDF v2 offers multiple drivers; they are not interchangeable in runtime requirements or rendering behavior. Its driver overview describes Browsershot, Gotenberg, Cloudflare, and Chrome as supporting modern CSS features; WeasyPrint as strong for CSS Paged Media; and DOMPDF for simpler layouts.
Recommended Free Tools
| Choice | What the documentation establishes | Consider it when |
|---|---|---|
| Browsershot | The Laravel PDF Browsershot driver depends on the Browsershot package and its runtime requirements. | You need browser rendering and can provide the required local runtime. |
| 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 access model. |
| Gotenberg or Chrome | The Laravel PDF introduction lists them among drivers supporting modern CSS features. The cited pages do not establish a performance ranking. | Compare their deployment and operational requirements with your environment before choosing. |
| WeasyPrint | The introduction describes it as strong for CSS Paged Media. | Your document depends on paged-media styling. |
| DOMPDF | The introduction positions it for simpler layouts; the PDF guide says it does not execute JavaScript. | Your output does not need JavaScript and its layout suits the driver. |
These descriptions are from Laravel PDF v2’s introduction and installation and setup guide. They are not a benchmark: choose based on CSS and JavaScript needs, deployment dependencies, and whether your team wants to operate a renderer or use a hosted service.
Validate input and control browser access
Spatie explicitly makes the caller responsible for validating HTML and URLs passed to Browsershot. Treat rendering as a security boundary because it starts a browser process, not as a harmless string conversion.
Rank #4
- Build documents from trusted templates and controlled data; do not pass arbitrary user-supplied markup directly to the renderer.
- Validate and restrict URL inputs to destinations your application is intended to fetch. Consider what the rendering environment can reach before accepting a URL.
- Keep the output path under application control rather than allowing a request to choose an arbitrary filesystem destination.
- Check local asset access. Browser restrictions may prevent access to local files; review any change that disables browser security and limit it to trusted inputs.
For the validation responsibility and PDF options, see Browsershot v4 PDF creation; local-resource customization is covered in the Laravel PDF setup guide.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Troubleshoot common rendering failures
Node, Puppeteer, or Chrome cannot be found
Check installed versions against Node.js 22.0+ and Puppeteer 23.0+, verify the browser binary exists in the generating environment, and configure paths using the Browsershot setup options if discovery fails. Review the requirements guide.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Images, fonts, or styles are missing
Confirm the browser process can reach the asset URLs or local resources and that permissions and browser restrictions permit access. If considering a security-setting change to allow local resources, assess the risk and use it only with trusted inputs.
Best Value
The PDF does not reflect JavaScript-rendered content
Use a browser-based driver when the page depends on JavaScript. Laravel PDF’s v2 documentation specifically states that DOMPDF does not execute JavaScript; verify the selected driver’s behavior rather than assuming all drivers render alike.
It works locally but fails after deployment
Compare the actual PHP, Laravel, Node.js, Puppeteer, browser, operating system, permissions, and container setup between environments. The documented version requirements alone do not establish compatibility with every deployment.
Or skip the browser setup
If your task is capturing a website screenshot rather than generating a Laravel PDF from a Blade view, ScreenshotNeo offers a one-call screenshot API. It is not a replacement for this Browsershot PDF workflow; it returns a screenshot or PDF of a URL.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorscurl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for the request options. Before capture, it accepts cookie or consent banners and removes 60+ known consent platforms, newsletter popups, and chat widgets; these steps can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and each response identifies the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 shots a month without a card; paid plans start at $5 for 3,000 shots.
Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.
Frequently Asked Questions
Can Browsershot render HTML without loading a URL?
Yes. Pass the HTML string to `Browsershot::html()` and save it with `savePdf()`, as shown above.
Can I use Laravel PDF if I do not want a local Node.js and Chrome installation?
Its Cloudflare driver uses the Browser Run API and does not require those binaries locally, but it requires Cloudflare credentials and service access.
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.




