Download the PHP package zentiq-labs/fast-pdf without Composer
On this page you can find all versions of the php package zentiq-labs/fast-pdf. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download zentiq-labs/fast-pdf
More information about zentiq-labs/fast-pdf
Files in zentiq-labs/fast-pdf
Package fast-pdf
Short Description Framework-agnostic, high-performance PHP-to-PDF rendering via direct headless Chromium IPC pipes. Works in Core PHP, Laravel, CodeIgniter 4, Symfony, and WordPress.
License MIT
Informations about the package fast-pdf
# Fast PDF
High-performance, sub-second, pixel-perfect HTML-to-PDF rendering for PHP applications powered by direct headless Chromium IPC pipes. Zero Node.js, NPM, or Puppeteer required. Zero framework lock-in.
Official Package: Maintained by Zentiq Labs.
For security disclosures and support, visit zentiqlabs.com.
Table of Contents
- Why Fast PDF?
- Requirements
- Installation
- Quick Start
- Configuration
- Fluent Builder API
- PHP Template Files
- Tailwind CSS Support
- Output Methods
- Paper Sizes & Orientation
- Framework Integration
- Core PHP
- CodeIgniter 4
- Symfony
- Laravel
- WordPress
- Docker & Alpine Linux
- Manual Test Script
- Testing
- Contributing
- License
Why Fast PDF?
Most PHP PDF solutions fall into one of two traps: they ship a bundled renderer with incomplete CSS support, or they delegate to a Node.js + Puppeteer stack — adding hundreds of megabytes and an IPC overhead tax to every request.
Fast PDF takes a third path. It speaks directly to the system's headless Chromium binary through native OS process pipes. Your HTML is rendered by the full Blink engine and the binary PDF stream is returned — no Node.js runtime, no browser automation framework, no intermediate file conversion.
| Approach | CSS Fidelity | Node.js | Framework Required |
|---|---|---|---|
| DOMPDF / mPDF | Partial (CSS 2.1) | No | No |
| Puppeteer / Playwright | Full | Yes | No |
| wkhtmltopdf | Partial (WebKit 2014) | No | No |
| Fast PDF | Full (Blink engine) | No | No |
Requirements
| Requirement | Version |
|---|---|
| PHP | ^8.3 |
| Chromium / Google Chrome | Any headless-capable build |
Chromium must be installed on the host. The package probes common system paths automatically and raises
BinaryNotFoundExceptionwith actionable instructions if it cannot locate a binary.
- Alpine Linux:
apk add chromium- Debian / Ubuntu:
apt-get install chromium-browser- macOS (Homebrew):
brew install --cask chromium
Installation
Quick Start
Configuration
Pass any subset of the configuration array to the constructor. Unset keys fall back to environment variables, then to built-in defaults.
Alternatively, publish and require the bundled config file:
Environment variables
| Variable | Default | Description |
|---|---|---|
FAST_PDF_BINARY |
(auto-discovered) | Absolute path to the Chromium binary |
FAST_PDF_TIMEOUT |
30 |
Max seconds before PdfGenerationFailedException |
FAST_PDF_PAPER_SIZE |
a4 |
Default paper size |
FAST_PDF_ORIENTATION |
portrait |
Default orientation |
FAST_PDF_MEDIA |
print |
CSS media type to emulate |
FAST_PDF_TAILWIND_CDN |
https://cdn.tailwindcss.com |
Tailwind standalone CDN URL |
FAST_PDF_TEMP_DIR |
sys_get_temp_dir() |
Scratch directory |
Fluent Builder API
All methods return $this and can be chained in any order.
| Method | Description |
|---|---|
fromHtml(string $html) |
Set a raw HTML string as the source |
fromFile(string $path, array $data = []) |
Render a PHP template file as the source |
paper(string $format = 'a4', string $orientation = 'portrait') |
Set paper format and orientation in one call |
paperSize(PaperSize\|string $size) |
Set paper size (see enum values) |
landscape() |
Landscape orientation |
portrait() |
Portrait orientation |
margins(float $t, float $r, float $b, float $l, string $unit = 'mm') |
Override margins. Unit: mm, cm, in, px |
withTailwind() |
Inject standalone Tailwind CDN before rendering |
emulateMedia(string $media = 'print') |
CSS media type: 'print' or 'screen' |
output(): string |
Render and return raw binary PDF bytes |
save(string $path) |
Render and write to a file path |
toInlineResponse(?string $filename = null): PdfResponse |
Return a PdfResponse for inline browser display (no exit) |
toDownloadResponse(?string $filename = null): PdfResponse |
Return a PdfResponse for file download (no exit) |
download(string $filename = 'document.pdf') |
Emit download headers, stream, and exit |
stream(string $filename = 'document.pdf') |
Emit inline headers, stream, and exit |
PHP Template Files
fromFile() works exactly like a simple view engine: variables in $data are extracted into the template scope, and the output buffer contents become the HTML source.
Tailwind CSS Support
Chain ->withTailwind() to inject the standalone Tailwind CDN script into the <head> before Chromium renders the page. No build pipeline required.
For offline environments or strict CSP policies, override
tailwind_cdn_urlto a self-hosted build of the Tailwind standalone CLI output.
Output Methods
Raw binary string
Save to disk
Browser download
Inline browser render
Paper Sizes & Orientation
Available PaperSize enum cases (accepts the lowercase string or the enum value):
A0 A1 A2 A3 A4 A5 A6 Letter Legal Tabloid Ledger
Framework Integration
Core PHP
CodeIgniter 4
Register a singleton in app/Config/Services.php:
Use it in a controller:
Symfony
Register as a service in config/services.yaml:
Inject into a controller or service via constructor injection:
Laravel
The package is framework-agnostic but integrates cleanly with Laravel via manual binding in a service provider:
Then inject FastPdf anywhere the service container resolves it.
WordPress
Paper Setup
The paper() method is a convenience shorthand for setting both the paper format and orientation in one call.
Supported formats: a0 a1 a2 a3 a4 a5 a6 letter legal tabloid ledger.
The individual paperSize(), landscape(), and portrait() methods remain available for finer-grained control.
Response Helpers
toInlineResponse() and toDownloadResponse() render the PDF and return a PdfResponse value object instead of calling exit. This fits naturally into any framework that manages its own response lifecycle.
PdfResponse exposes:
$response->body— raw binary PDF bytes$response->headers— associative array of HTTP header name → value$response->send()— emit headers + body via the PHP SAPI
For Symfony or any PSR-7 framework:
Testing with FastPdf::fake()
Call FastPdf::fake() to get an instance that records every render call without spawning Chromium.
The fake returns %PDF-1.4 fake bytes by default. This is intentional — unit tests should not depend on real PDF content. To override the fake output, reach into the engine:
Docker & Alpine Linux
A ready-to-use test image is included in docker/Dockerfile.test. It runs the full Pest suite against a real Chromium binary inside an Alpine container.
Minimal additions for your own application Dockerfile:
Always include --no-sandbox and --disable-setuid-sandbox in chromium_flags (the package defaults already include them) when running inside unprivileged Docker containers.
Manual Test Script
A standalone smoke-test script is included at bin/test-render.php. It generates a Tailwind-styled invoice PDF to output.pdf in the current working directory.
Testing
With coverage:
Static analysis (PHPStan level 9):
Code style (PSR-12):
Contributing
Contributions, issues, and feature requests are welcome. Please ensure any pull request:
- Targets the
developbranch. - Ships with corresponding test coverage for all new behaviour.
- Passes the full CI pipeline (
test,check,cs) locally before opening a PR. - Follows Conventional Commits.
License
The MIT License (MIT). See LICENSE for details.
Developed and maintained by Usman Khan at Zentiq Labs.