The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →To convert a live URL to PDF in PHP, use Spatie Browsershot for a concise URL-to-file API, or chrome-php/chrome when you need more direct control over Chrome and print settings. Both rely on an installed browser runtime; Chrome’s headless command line is the simplest route if you are comfortable managing the process yourself.
Choose a PHP-to-PDF method
| Method | How PHP reaches Chrome | Best fit | Documented PDF controls |
|---|---|---|---|
| Browsershot | PHP package delegates browser automation to Puppeteer and headless Chrome. | A short PHP API for saving a URL as a PDF. | URL, HTML string, or local HTML file input; consult current package documentation for detailed print options. |
| chrome-php/chrome | PHP controls Chrome or Chromium through a browser/page API. | Direct lifecycle and page control, or documented print configuration. | Orientation, paper dimensions, margins, scale, background printing, CSS @page sizing, headers and footers, and streaming. |
| Chrome CLI | PHP launches the installed Chrome executable as a process. | A command-line workflow with process management handled by the application. | Print-to-PDF, header/footer suppression, a maximum capture wait, and virtual-time budget. |
Compatibility information changes over time. The Browsershot 5.4.0 Packagist listing checked on 2026-10-03 showed PHP ^8.2; the release date listed was 2026-05-26. The chrome-php/chrome README lists PHP 7.4–8.5 and Chrome/Chromium 65+ as requirements. Confirm current requirements and production setup before installing: Packagist: spatie/browsershot, Browsershot README, chrome-php/chrome README.
Use Browsershot for a concise PHP API
Install the package with Composer, then pass the URL to Browsershot::url() and save to a path ending in .pdf. The project describes Browsershot as using Puppeteer to control headless Chrome, so this is not a PHP-only renderer. Check the project’s current requirements for the correct browser/Puppeteer setup in your deployment; the test-suite installation instructions alone should not be assumed to describe production installation.
composer require spatie/browsershot
<?php
require __DIR__ . '/vendor/autoload.php';
use SpatieBrowsershotBrowsershot;
Browsershot::url('https://example.com')
->save(__DIR__ . '/example.pdf');
The URL can also be replaced with HTML content or a local HTML file using the package’s corresponding API. For detailed configuration, follow the current Browsershot documentation.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Use chrome-php/chrome for direct browser and print control
This pattern creates a browser, opens a page, navigates, waits for navigation, writes a PDF, and closes Chrome even if an earlier operation fails. The README’s documented installation command is:
composer require chrome-php/chrome
<?php
require __DIR__ . '/vendor/autoload.php';
use HeadlessChromiumBrowserFactory;
$browser = (new BrowserFactory())->createBrowser();
try {
$page = $browser->createPage();
$page->navigate('https://example.com')->waitForNavigation();
$page->pdf(['printBackground' => true])->saveToFile(__DIR__ . '/example.pdf');
} finally {
$browser->close();
}
The PDF call accepts print settings, including orientation, margins, paper dimensions, scale, whether to print backgrounds, and whether CSS @page size should take precedence. Header and footer templates can use classes for date, title, URL, page number, and total page count. The PDF can be saved to a file or streamed to a PHP output stream. See the project README for the library’s current option names and usage.
Selecting the Chrome executable
The library documents the CHROME_PATH environment variable for selecting the executable, and also allows an executable name to be passed to BrowserFactory. This is useful when Chrome is installed outside the system path or a deployment provides a specific browser binary.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Choosing when navigation is ready
The default navigation wait is for the load event. The library also documents other events, including DOM content loaded and network idle. A page that continues fetching background resources or fills in content after initial navigation may need a different wait condition. Whichever event you choose, handle navigation timeouts: no readiness event guarantees that every site’s dynamic content is complete.
Free tools Windows power users keep installed
One-click scans. No signup required.
Use Chrome’s headless CLI when a process call is enough
Chrome’s headless command-line reference documents direct PDF printing:
chrome --headless --print-to-pdf https://example.com/
Chrome saves output.pdf in the current working directory. Add --no-pdf-header-footer to omit Chrome’s generated date, URL, and page headers and footers. --timeout=5000 sets a maximum wait of five seconds before capture; it can therefore produce a PDF before a slow page is ready. --virtual-time-budget advances time-dependent page code during capture. See the Chrome Headless command-line reference (documentation last updated 2024-10-21) for flag behavior.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
To call this from PHP, your application must launch the installed Chrome binary and manage the process. The Chrome documentation describes the CLI flags, not a PHP process-launch implementation. Treat executable discovery, shell argument quoting, process timeouts, exit status, and stderr handling as part of your own integration; avoid assembling a shell command by concatenating an untrusted URL.
Make the PDF match the page you intend to deliver
- Choose a print layout: set paper size, orientation, margins, and scale deliberately when using the PHP PDF controls. A page’s screen layout and its printed layout may differ.
- Decide whether backgrounds belong: enable background printing when the PDF must retain background colors or graphics; omit it when a cleaner print-style page is preferable.
- Set readiness for the site: wait for a suitable navigation event or use the CLI timeout/virtual-time options where appropriate. A shorter bound may reduce waiting but increases the risk of capturing an incomplete page.
- Plan browser lifecycle: close the browser in a
finallyblock when using the direct PHP API. For a CLI integration, enforce a process timeout and inspect its result before treating the output file as successful. - Use an absolute output path: it makes the destination predictable across working directories and simplifies checking whether a file was created.
Rendering depends on the site, its load behavior, the installed browser, and the selected print settings. The cited documentation does not establish a universal rendering time or guarantee identical output for every page.
Troubleshoot common failures
Chrome or Puppeteer cannot be found
Check that the browser runtime required by the selected integration is installed in the environment where PHP runs. For chrome-php/chrome, set CHROME_PATH or configure the executable explicitly if Chrome is not discoverable. For Browsershot, verify the production Puppeteer/Chrome setup against its current requirements.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Navigation times out or the PDF is incomplete
A page may continue loading resources or render content after its initial navigation event. Choose a more suitable wait event where the library permits it, and configure a timeout appropriate to the page. With the CLI, a maximum timeout can deliberately capture before loading finishes; use virtual time for pages whose scripts depend on elapsed time, where suitable.
The PDF is missing colors, headers, or expected sizing
Review the print options rather than assuming screen appearance maps directly to paper. Enable background printing if needed, inspect orientation and margins, and decide whether CSS @page sizing should control the output. Header/footer templates and Chrome’s generated headers are separate concerns; the CLI’s --no-pdf-header-footer suppresses the latter.
The output file is missing or stale
Confirm the process completed successfully, the destination directory is writable, and the application is checking the same path used by the save operation. For a CLI call, capture the exit code and diagnostics; do not infer success solely because PHP launched the process.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Or skip the browser setup
If the job is to capture a page rather than manage Chrome in your PHP runtime, ScreenshotNeo offers a screenshot API and MCP server. The example below is the supplied one-call screenshot request; consult the ScreenshotNeo documentation for PDF output settings and API options.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
- Before capture, it accepts cookie/consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off.
- Bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing; response headers report the page verdict and whether the request was billed.
- An MCP server provides
take_screenshot,get_page_info, andcapture_pdftools for Claude, Cursor, and other MCP clients. - The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Every feature is on every plan.
Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.
FAQ
Can PHP render a URL to PDF without Chrome?
The methods here use Chrome or Chromium for browser rendering; Browsershot additionally delegates automation through Puppeteer. They are not PHP-only rendering engines.
Can I convert HTML rather than a public URL?
Browsershot documents URL, HTML string, and local HTML file input. The direct Chrome APIs operate on a browser page, so load or construct the page content before invoking PDF output.
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.

