Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk5 min

How to Create a PDF from a URL in Laravel with Snappy

A practical Laravel Snappy guide to rendering a webpage URL as a PDF, configuring wkhtmltopdf, choosing output behavior and avoiding unsafe URL fetching.

Free tools Windows power users keep installed

One-click scans. No signup required.

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

Use Laravel Snappy’s PDF::loadFile($url) to ask wkhtmltopdf to render a webpage, then return it inline or as a download. Laravel Snappy is a wrapper, not the PDF renderer: install the wkhtmltopdf executable separately, configure its path for the server, and treat every URL supplied by a caller as a potentially unsafe server-side network request.

Install Laravel Snappy and wkhtmltopdf

  1. Install the Laravel package with Composer:

    composer require barryvdh/laravel-snappy
  2. Install wkhtmltopdf in the deployment environment, or use a Composer binary dependency. Confirm the executable runs from the command line on the same host or container that serves Laravel.

    As an Amazon Associate I earn from qualifying purchases.

  3. Publish and inspect the package configuration using the Artisan command documented by Laravel Snappy’s README. Set the binary value in config/snappy.php to the actual wkhtmltopdf executable path, and verify that the web process has permission to execute it.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  4. Use the documented PDF facade only if its alias is available in your Laravel setup. Otherwise resolve the package’s PDF service through the configured container binding.

    #1 Best Overall
    Sale
    Epson Workforce ES-50 Compact & Lightweight Mobile Document Scanner | For Computers including PC and Mac Receipt and Document Scanner USB Powered
    • PORTABLE SCANNER FOR USE ON-THE-GO — The fastest and lightest mobile single-sheet-fed compact document scanner in its class¹
    • QUICK DOCUMENT SCANNING ― This Epson ultra-fast scanner scans a single page as quickly as 5.5 seconds²; Windows and Mac compatible
    • VERSATILE PAPER HANDLING ― Portable scanner scans documents up to 8.5 x 72 in; Also easily digitizes receipts and ID cards to make accounting, bookkeeping, and organizing simpler
    • INTUITIVE, HIGH-SPEED SOFTWARE — Epson ScanSmart Software³ is a smart tool allowing you to easily scan, review, and save; Stay organized easily with the help of this Epson scanner
    • EASY SETUP — USB-powered connect to your computer for quick and simple scanning; No batteries or external power supply required to operate portable document scanner; Standard Connectivity: USB 2.0

The package delegates conversion to KnpLabs Snappy, which invokes wkhtmltopdf; a working Laravel installation without a reachable, executable binary is not enough. See the KnpLabs Snappy README for the lower-level wrapper behavior.

Load a URL and return the PDF

For a browser response that displays the result inline:

<?php

use IlluminateSupportFacadesRoute;

Route::get('/reports/page', function () {
    $url = 'https://example.com';

    return PDF::loadFile($url)->inline('page.pdf');
});

To ask the browser to download it instead, change the final call:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
return PDF::loadFile($url)->download('page.pdf');

For a lower-level service call that writes the generated file to storage:

Rank #2
Sale
Brother DS-640 Compact Mobile Document Scanner, (Model: DS640)
  • FAST SPEEDS - Scans color and black and white documents a blazing speed up to 16ppm (1). Color scanning won’t slow you down as the color scan speed is the same as the black and white scan speed.
  • ULTRA COMPACT – At less than 1 foot in length and only about 1. 5lbs in weight you can fit this device virtually anywhere (a bag, a purse, even a pocket).
  • READY WHENEVER YOU ARE – The DS-640 mobile scanner is powered via an included micro USB 3. 0 cable allowing you to use it even where there is no outlet available. Plug it into you PC or laptop and you are ready to scan.
  • WORKS YOUR WAY – Use the Brother free iPrint&Scan desktop app for scanning to multiple “Scan-to” destinations like PC, Network, cloud services, Email and OCR. (2) Supports Windows, Mac and Linux and TWAIN/WIA for PC/ICA for Mac/SANE drivers. (3)
  • OPTIMIZE IMAGES AND TEXT – Automatic color detection/adjustment, image rotation (PC only), bleed through prevention/background removal, text enhancement, color drop to enhance scans. Software suite includes document management and OCR software. (4)
$snappy = App::make('snappy.pdf');
$snappy->generate('https://example.com', storage_path('app/page.pdf'));

Snappy also supports loading HTML produced by your application, for example with PDF::loadHTML($html). That is a different input path from loadFile, which loads a URL or file through the renderer.

Set paper size, orientation and renderer options

Set layout and conversion options through the wrapper. This example saves an A4 landscape PDF with no bottom margin:

$pdf = PDF::loadHTML($html)
    ->setPaper('a4')
    ->setOrientation('landscape')
    ->setOption('margin-bottom', 0);

return $pdf->download('report.pdf');

For URL captures, the same renderer options can be applied after loadFile($url). wkhtmltopdf documents A4, portrait and 10 mm left and right margins among its defaults; defaults and supported options can depend on the deployed binary, so check its usage manual rather than assuming a setting is identical across installations.

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

Options documented by the renderer include JavaScript delay, load-error handling, print-media mode, headers and footers. The wrapper accepts renderer options with setOption; use the corresponding wkhtmltopdf option name and validate the output in the target environment.

Rank #3
Sale
Canon imageFORMULA R10 - Portable Document Scanner, USB Powered, Duplex Scanning, Document Feeder, Easy Setup, Convenient, Perfect for Mobile Users, White
  • STAY ORGANIZED – Easily convert your paper documents into digital formats like searchable PDF files, JPEGs, and more.Power Consumption : 2.5W or less (Energy Saving Mode: 0.7W). Suggested Daily Volume : 500 scans..Does it contain liquid: no
  • CONVENIENT AND PORTABLE –lightweight and small in size, you can take the scanner anywhere from home offices, classrooms, remote offices, and anywhere in between
  • HANDLES VARIOUS MEDIA TYPES – Digitize receipts, business cards, plastic or embossed cards, reports, legal documents, and more
  • FAST AND EFFICIENT – No technical hurdles or complicated setups here; easily scan both sides of a document at the same time, in color or black-and-white, at up to 12 pages-per-minute, and with a 20 sheet automatic feeder
  • BROAD COMPATIBILITY – Works with both Windows and Mac devices, be it laptop or computer

What happens when wkhtmltopdf loads a webpage

The conversion runs on the application server, not in the visitor’s browser. That server must be able to reach the target URL and any assets the page needs. Authentication, redirects, bot checks, JavaScript-heavy interfaces and network restrictions can change what ends up in the PDF; the package and renderer documentation do not establish that arbitrary sites will render consistently.

If a page needs cookies, headers or a proxy, Snappy and wkhtmltopdf document related configuration options. Configure only what the actual target requires, and test with the same binary, network access and runtime identity used in production.

Protect URL-to-PDF endpoints

A route that accepts a URL and asks a server-side process to fetch it can become a way to reach internal services or sensitive addresses. Prefer a fixed destination or a strict allowlist of permitted hosts; validate the scheme and destination before passing the URL to Snappy. The reviewed package documentation does not provide a complete Laravel-specific allowlist implementation.

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.
  • Do not pass arbitrary caller-supplied URLs directly to loadFile.

    Rank #4
    IRIScan Express 4 Black Compact Portable USB Simplex Document Scanner, 8 PPM for Contracts, Invoices and Business Cards, Compatible with Windows, Readiris PDF Included
    • IRIScan Express, portable scanner : scans color and black and white documents a blazing speed up to 8ppm simplex. Color scanning won’t slow you down as the color scan speed is the same as the black and white scan speed.
    • IRIScan Express mobile scanner is powered via an included micro USB 2. 0 cable allowing you to use it even where there is no outlet available. Plug it into you PC or laptop and you are ready to scan. USB cable provided. AC Adapter not provided and not needed.
    • IRIScan flatbed scanner uses a simplex scanning mode allows for quick and straightforward scanning of single-sided documents. IRIScan with its full portable features is the ideal document scanners for computers.
    • IRIScan document scanner : Versatile scanning capabilities, including scanning to Word, PDF, and Excel formats with companion software provided Readiris OCR
    • Receipt scanner and card scanner with Additional features include scanning business cards directly to Outlook, photo scanning, and receipt scanning for efficient document management
  • Do not enable wkhtmltopdf local-file access just to work around a missing web asset. The renderer manual says local-file access is disabled by default for local-file conversions unless paths are explicitly allowed.

  • Avoid rendering untrusted HTML or JavaScript. The KnpLabs Snappy README warns that --enable-local-file-access can be risky with untrusted HTML or JavaScript and recommends sanitizing inputs and using a sandbox such as AppArmor or SELinux.

The wkhtmltopdf status page says Qt 4 has been unsupported since 2015 and the bundled WebKit has not been updated since 2012. Its maintainer warns against using wkhtmltopdf with untrusted HTML and names WeasyPrint or commercial Prince for controlled report generation, and Puppeteer for sites that rely on dynamic JavaScript. These are the project’s recommendations, not a comparative test; check current support and deployment requirements before choosing a replacement.

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

Troubleshoot common failures

Symptom Likely cause What to check
Laravel reports that the binary cannot be found or started The configured binary path is incorrect, the executable is absent, or the web process lacks permission. Run the binary on the deployment host, correct config/snappy.php, and check executable permissions for the application’s runtime user.
The PDF is blank or missing images and styles The renderer could not reach the page or its assets, or the page was not ready when conversion occurred. Check network access from the server, asset URLs and renderer output; if JavaScript is involved, evaluate the documented delay or page-loading options.
The output differs from the browser view The renderer’s engine, print-media behavior, JavaScript support or page access conditions differ from the browser being compared. Check the wkhtmltopdf manual for the deployed binary’s options. For a site that depends on modern dynamic JavaScript, evaluate a renderer such as Puppeteer rather than assuming a Snappy setting will reproduce the page.
Private or authenticated content does not appear The server-side renderer does not automatically share the visitor’s browser session. Configure only the required cookies or headers using documented renderer options, and avoid accepting credentials or destinations from untrusted callers.
Enabling local-file access appears to fix missing assets The page may be referencing local paths that the renderer cannot read under its default restrictions. Prefer accessible, properly served assets. Enable local-file access only if the use case requires it and the conversion is isolated and constrained.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If the goal is a clean screenshot or PDF of a public page rather than a Laravel-hosted wkhtmltopdf workflow, ScreenshotNeo offers a website screenshot API and MCP server. One GET request can return a PDF; the service accepts cookie banners before capture and removes more than 60 known consent platforms, newsletter popups and chat widgets. Those cleanup steps can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info and capture_pdf for AI agents.

cURL example, using the documented API endpoint and parameters:

Best Value
Canon Canoscan Lide 300 Scanner (PDF, AUTOSCAN, Copy, Send)
  • Scanner type: Document
  • Connectivity technology: USB
  • With Auto Scan Mode, the scanner automatically detects what you're scanning
  • Digitize documents and images
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.pdf

See the ScreenshotNeo API documentation for PDF response options and available parameters. The service offers 1,000 screenshots a month free with no card; paid plans start at $5 for 3,000 shots. Sign up for the free plan.

Frequently Asked Questions

Can Laravel Snappy convert a URL directly, without first saving its HTML?

Yes. Pass the URL to PDF::loadFile($url), then return the result with inline() or download().

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

Does Laravel Snappy include wkhtmltopdf?

No. Install or otherwise provide the wkhtmltopdf executable and configure its path for the deployment environment.

Quick Recap

SaleBestseller No. 3
Canon imageFORMULA R10 - Portable Document Scanner, USB Powered, Duplex Scanning, Document Feeder, Easy Setup, Convenient, Perfect for Mobile Users, White
Canon imageFORMULA R10 - Portable Document Scanner, USB Powered, Duplex Scanning, Document Feeder, Easy Setup, Convenient, Perfect for Mobile Users, White
BROAD COMPATIBILITY – Works with both Windows and Mac devices, be it laptop or computer; This product is not intended for scanning photographs on photo paper / photographic media
$153.00
Bestseller No. 4
IRIScan Express 4 Black Compact Portable USB Simplex Document Scanner, 8 PPM for Contracts, Invoices and Business Cards, Compatible with Windows, Readiris PDF Included
IRIScan Express 4 Black Compact Portable USB Simplex Document Scanner, 8 PPM for Contracts, Invoices and Business Cards, Compatible with Windows, Readiris PDF Included
Find our Software here : irislink.com/start; IRIScan Express is only compatible Windows platform and not macintosh
$129.00
Bestseller No. 5
Canon Canoscan Lide 300 Scanner (PDF, AUTOSCAN, Copy, Send)
Canon Canoscan Lide 300 Scanner (PDF, AUTOSCAN, Copy, Send)
Scanner type: Document; Connectivity technology: USB; With Auto Scan Mode, the scanner automatically detects what you're scanning
$75.00

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.