Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Guzzle does not convert web pages to PDF. It is an HTTP client: it requests a URL and gives your PHP application the response body. To create a PDF, pass that HTML to a PDF renderer such as Browsershot (Puppeteer and headless Chrome) or Dompdf. For pages that depend on JavaScript, browser navigation is usually the more faithful workflow.

What Guzzle does—and what it does not do

Guzzle is a PHP HTTP client for sending requests and receiving responses. You can read the response body as a PSR-7 stream, inspect status codes and headers, follow an application-defined request flow, and supply authentication or cookies. None of those operations lays out a document or writes a PDF.

PDF creation is a second operation performed by a renderer. The renderer must parse HTML, resolve styles and assets, calculate page breaks, and write a PDF file. Treating (string) $response->getBody() as a PDF conversion step is therefore incorrect.

Choose the conversion workflow

Use direct browser navigation for a browser-rendered page

Spatie Browsershot documents URL-to-PDF and HTML-to-PDF methods. It uses Puppeteer to control headless Chrome, so Chrome can execute page JavaScript and load resources as a browser session. This is the better starting point for single-page applications, pages whose content appears after JavaScript runs, and layouts that use current browser CSS.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • 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.
<?php

require __DIR__ . '/vendor/autoload.php';

use SpatieBrowsershotBrowsershot;

Browsershot::url('https://example.com')
    ->savePdf(__DIR__ . '/output/example.pdf');

This code is a renderer call, not a Guzzle call. Your deployment must provide the Browsershot, Puppeteer and headless-Chrome runtime described by the version of Browsershot you installed. Confirm those requirements against the v4 documentation and your installed package versions.

Fetch HTML with Guzzle, then render that supplied HTML

Use this shape when your application must control the HTTP request—for example, to add an authorization header, obtain content from an API, or save an intermediate response.

<?php

require __DIR__ . '/vendor/autoload.php';

use GuzzleHttpClient;
use SpatieBrowsershotBrowsershot;

$client = new Client([
    'timeout' => 15,
    'allow_redirects' => true,
]);

$response = $client->get('https://example.com');
$status = $response->getStatusCode();
$contentType = $response->getHeaderLine('Content-Type');

if ($status < 200 || $status >= 300) {
    throw new RuntimeException("The source returned HTTP {$status}");
}

if (stripos($contentType, 'text/html') === false) {
    throw new RuntimeException('The response is not HTML');
}

$html = (string) $response->getBody();

Browsershot::html($html)
    ->savePdf(__DIR__ . '/output/example.pdf');

A response string is not necessarily the final page a browser would see. Relative image, stylesheet and font URLs may no longer resolve correctly when markup is rendered outside its original URL. The page may also require cookies, redirects, client-side data fetching, or JavaScript. If those conditions matter, let Browsershot navigate to the destination URL and configure the browser request rather than assuming fetched HTML is equivalent.

Build a production-ready Guzzle-to-PDF pipeline

  1. Validate the input. Parse the URL, allow only schemes you support (normally HTTPS), and apply an allowlist of hosts when users can submit URLs.
  2. Request with explicit limits. Set a connect timeout and total timeout, decide whether redirects are allowed, and enforce a maximum response size before buffering a large body.
  3. Check the response. Handle status codes, content type, redirect destinations and an empty body. Do not send an error page to the renderer as if it were the requested document.
  4. Choose URL or HTML input. Use URL navigation when browser execution and resource loading are needed; use supplied HTML when your application owns the markup and its assets.
  5. Render to a controlled path. Use a non-user-writable output directory, create unique filenames, and verify that the renderer completed before returning the file.
  6. Deliver safely. Set an appropriate PDF content type, use an application-generated download name, and avoid exposing filesystem paths in errors.

When Dompdf is enough

Dompdf is a separate PHP HTML-to-PDF renderer. It can be appropriate for controlled invoices, reports and templates that fit its supported layout model. Its project documentation describes mostly CSS 2.1 support and identifies important limits, including no flexbox or grid support and table-cell pagination restrictions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 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.

Choose Dompdf when avoiding a Chrome runtime is more important than browser-level fidelity and your templates use conservative HTML and CSS. Choose Browsershot when the target page uses modern CSS, complex responsive layout, web fonts, canvas, or JavaScript. Render representative documents in the actual deployment environment; documentation alone cannot predict the exact output of your page.

Requirement Browsershot with headless Chrome Dompdf
JavaScript-dependent content Browser execution is available Not a browser execution workflow
Modern CSS and responsive layout Generally closer to Chrome rendering Mostly CSS 2.1; flexbox and grid are documented limitations
Runtime PHP plus Puppeteer and a compatible Chrome runtime PHP renderer without a Chrome process
Best input A URL or HTML, depending on whether browser loading is required Controlled HTML compatible with its layout support
Remote resources Loaded by the browser session, subject to your configuration Require deliberate remote-resource configuration and security review

Authentication, cookies and assets

Guzzle can send headers, cookies and credentials while fetching HTML. If the renderer later navigates to the URL itself, those credentials must also be available to that browser session; they do not automatically transfer from a separate Guzzle request. Conversely, when supplying HTML, you must make relative assets resolvable or rewrite them to permitted absolute URLs.

  • Prefer short-lived, least-privilege credentials.
  • Do not place bearer tokens in query strings or generated PDF filenames.
  • Decide whether external images, CSS and fonts are allowed, and restrict their hosts.
  • Check character encoding and font availability when text appears missing or substituted.

Security boundaries you should enforce

User-controlled URLs and HTML are untrusted input. Browsershot places URL and HTML validation responsibility on the caller. An unrestricted fetch endpoint can be abused to reach internal services, cloud metadata endpoints, private network addresses or unexpectedly large responses.

  • Allow only approved URL schemes and hosts; resolve DNS and block private or loopback address ranges where your threat model requires it.
  • Limit redirects and validate every redirect destination, not only the first URL.
  • Set connect, request and rendering timeouts, plus response and output-size limits.
  • Run browser and rendering workers with a restricted service account and isolated temporary directories.
  • For Dompdf, keep remote resources disabled unless required, restrict permitted resources, and keep embedded PHP disabled for untrusted documents. Its documentation describes remote-resource and embedded-script risks.
  • Sanitize or reject user-supplied HTML rather than assuming a PDF renderer is a security boundary.

Reliability and performance considerations

Browser rendering costs more CPU and memory than reading a response body. Reuse workers where your process manager supports it, avoid launching several large Chrome jobs without a queue limit, and put long conversions on a background queue. Set a deterministic viewport and wait strategy when page timing affects output. Capture logs for the source URL, status, renderer exit code and duration, but never log secrets.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • 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.

Guzzle buffering is convenient for small documents. For untrusted or potentially large pages, enforce a maximum body size and reject content before allocating excessive memory. Cache only when the source and authorization policy permit it; a cached private document must not become publicly downloadable. Always inspect page breaks, images, fonts, backgrounds and the final file in the target environment.

Common failures and fixes

“The PDF contains a blank page”

Check the HTTP status and body first. A timeout, bot challenge or JavaScript shell may have been rendered as empty content. Try direct Browsershot URL navigation, increase the wait strategy for the page’s data, and capture diagnostic HTML or a browser screenshot.

“The HTML is present but images or CSS are missing”

Supplied HTML may contain relative URLs whose original base URL was lost. Rewrite asset URLs, provide a suitable base element, or use direct browser navigation. Check authentication and whether the renderer is permitted to reach each asset host.

“Modern layout is broken in Dompdf”

Replace flexbox or grid with supported layout rules for a controlled template, or switch to Browsershot when browser fidelity is required. Verify table widths and page-break behavior rather than assuming CSS from the web page will transfer.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • 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

“The request hangs”

Set connection and total timeouts, cap redirects, and identify whether the delay is Guzzle, the browser startup, a third-party asset, or page JavaScript. Queue the job and return a status to the caller instead of holding a web request indefinitely.

“The PDF has the wrong authenticated view”

Credentials used by Guzzle are not automatically present in a later browser navigation. Pass cookies or headers through the browser configuration, or render the authenticated HTML that Guzzle fetched after checking that its assets remain accessible.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server. A single request can return PNG, JPEG, WebP or PDF, so it can replace a self-managed browser for a straightforward URL capture. See the ScreenshotNeo API documentation for request options.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

Before capture, ScreenshotNeo accepts cookie and consent banners and removes more than 60 known consent platforms, newsletter popups and chat widgets; each cleanup step can be disabled. Bot checks, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and billing result. Its MCP server provides take_screenshot, get_page_info and capture_pdf for Claude, Cursor and other MCP clients. The free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 shots. Create an account at ScreenshotNeo’s free sign-up page.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Final decision

Use Guzzle when you need controlled HTTP retrieval, not as the PDF engine. For browser-faithful output, let Browsershot navigate the URL. For application-owned markup, fetch with Guzzle and pass the validated HTML to a renderer. Use Dompdf for compatible, controlled templates, and enforce URL, resource and markup security limits in every workflow.

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 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.

Frequently Asked Questions

Can Guzzle save a URL directly as a PDF?

No. Guzzle retrieves HTTP responses. A PDF renderer such as Browsershot or Dompdf must create the PDF.

Should I pass Guzzle HTML to Browsershot or give Browsershot the URL?

Pass the URL when JavaScript, authenticated browser loading or relative assets are important. Pass HTML when your application controls the complete markup and asset handling.

Is Dompdf a drop-in replacement for Chrome?

No. Dompdf has a different CSS and layout compatibility profile, including documented limits around flexbox, grid and table pagination.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.