Download the PHP package beganovich/snappdf without Composer
On this page you can find all versions of the php package beganovich/snappdf. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download beganovich/snappdf
More information about beganovich/snappdf
Files in beganovich/snappdf
Package snappdf
Short Description Convert webpages or HTML into the PDF file using Chromium or Google Chrome.
License MIT
Informations about the package snappdf
snappdf
A simple library that lets you convert webpages or HTML into PDF files using Chromium-powered browsers.
Features
- Fast — Generates PDFs in under 0.5 seconds with cold start
- No Node.js required — Communicates directly with the browser
- Minimal API — Focused solely on PDF generation
- Local Chromium — Downloads and manages its own Chromium revision
- Flexible configuration — Custom binary path, arguments, and environment variables
- Smart timing — Virtual time budget for waiting on async content
Requirements
- PHP ^8.2
Installation
Quick Start
Usage
From HTML
From URL
Custom Chromium Path
Laravel with Blade
Symfony Filesystem
Environment Variable
Nginx example:
Generate Without Saving
Stream to Browser
Priority: setChromiumPath() takes precedence, then SNAPPDF_EXECUTABLE_PATH, then local Chromium download.
Configuration
Chromium Arguments
Remove a single argument:
Override all default arguments with the SNAPPDF_EXECUTABLE_ARGUMENTS environment variable.
Note:
--print-to-pdfis always added.--virtual-time-budgetis added whenwaitBeforePrinting()is called.
Clear all arguments:
CLI Usage
Speed
snappdf communicates directly with the browser, generating PDFs in under 0.5 seconds with cold start on mid-range hardware (i5-5300U, SSD).
Chromium Management
Local Download
Downloads are stored in vendor/beganovich/snappdf/versions. The local revision is used only when no path is provided via setChromiumPath().
Note: snappdf downloads the latest Chromium build. Since Chromium has no stable or unstable releases, the browser may occasionally be buggy. For production environments, install Google Chrome stable and point the package to it.
Skip Download
Set the SNAPPDF_SKIP_DOWNLOAD environment variable to skip downloading Chromium.
Troubleshooting
If Chrome doesn't launch on UNIX, ensure the required system dependencies are installed. See Puppeteer's troubleshooting guide.
Debian (e.g. Ubuntu)
Note: You might also need `libgbm-dev` and `libxshmfence-dev` (reported for Ubuntu 20.04).CentOS
After installing dependencies, update nss:Related discussions
- [#290](https://github.com/puppeteer/puppeteer/issues/290) — Debian troubleshooting - [#391](https://github.com/puppeteer/puppeteer/issues/391) — CentOS troubleshooting - [#379](https://github.com/puppeteer/puppeteer/issues/379) — Alpine troubleshootingSmart Delay
Use waitBeforePrinting() to set a maximum delay (in milliseconds) before printing. This is useful for waiting on AJAX calls or chart libraries to finish loading.
If your AJAX call completes in 2 seconds, rendering starts immediately — it won't wait the full 10 seconds.
Temporary Files
Since version 3, snappdf cleans up temporary files automatically. To keep them:
Comparison to Browsershot
For more complex headless browser operations, use Spatie's Browsershot. snappdf is intentionally minimal — it only does PDFs and doesn't require Node.js.
Testing
Credits
License
The MIT License (MIT). See LICENSE for more information.
All versions of snappdf with dependencies
ext-zip Version *
symfony/process Version ^7.4 | ^8.0
symfony/console Version ^7.4 | ^8.0
symfony/filesystem Version ^7.4 | ^8.0