Laravel Forge
Generate PDFs on Laravel Forge
How to generate professional PDFs on Laravel Forge without the headache of installing and maintaining Chrome
The Challenge
Laravel Forge gives you powerful server management, but generating PDFs with headless Chrome brings a host of problems:
- Complex installation - Chrome dependencies, sandbox issues, font packages
- Resource hungry - Chrome consumes 500MB+ RAM per instance
- Security concerns - Running a browser on your production server
- Maintenance burden - Chrome updates, memory leaks, zombie processes
You can install Chrome on Forge, but should you?
Why Self-Hosting Chrome Is Painful
Memory Problems
Chrome is designed for desktop use, not server workloads. Each PDF generation:
- Spawns a new browser process (or reuses a leaky one)
- Loads your entire HTML document into memory
- Renders fonts, images, and CSS
- Converts to PDF
On a $20/month Forge server, a few concurrent PDF requests can exhaust your memory and crash your application.
Installation Headaches
Getting Chrome to run on Ubuntu involves:
# The "simple" installation
apt-get install -y chromium-browser
apt-get install -y fonts-liberation fonts-noto-color-emoji
apt-get install -y libx11-xcb1 libxcomposite1 libxdamage1 ...
Then you deal with sandbox errors, missing libraries, and permission issues. Every server rebuild means doing it again.
Security Risks
Running a browser engine on your production server:
- Expands your attack surface
- Can be exploited via malicious HTML input
- Requires keeping Chrome updated for security patches
Why DomPDF Isn't the Answer
Many developers fall back to DomPDF to avoid Chrome, but it can't handle modern CSS:
- No Flexbox -
display: flexis ignored - No Grid -
display: griddoes nothing - Broken Tailwind - Most utility classes fail
- Poor fonts - Custom fonts require manual configuration
Your beautiful Tailwind invoices become broken messes.
The TailPDF Solution
TailPDF moves PDF generation off your server entirely. You send HTML, we send back a PDF.
Why it's better than self-hosting:
- Zero server configuration - No Chrome, no dependencies
- Predictable resource usage - Just HTTP requests
- Always updated - We handle Chrome versions and security
- Scales independently - PDF load doesn't affect your app
Quick Start
Install the TailPDF Laravel package via Composer:
composer require mralston/tailpdf
Add your API key to .env:
TAILPDF_API_KEY=your-api-key-here
Generate PDFs from your Blade views:
use Mralston\Tailpdf\Facades\TailPdf;
// Generate a PDF from a Blade view and download
return TailPdf::view('reports.monthly', ['data' => $data])
->pdf()
->download('report.pdf');
Save to disk:
use Mralston\Tailpdf\Facades\TailPdf;
// Save PDF to storage
TailPdf::view('invoices.show', ['invoice' => $invoice])
->pdf()
->save('invoices/invoice-' . $invoice->id . '.pdf');
Stream to browser:
use Mralston\Tailpdf\Facades\TailPdf;
// Stream PDF directly to browser
return TailPdf::view('contracts.show', ['contract' => $contract])
->pdf()
->stream();
Get raw PDF content:
use Mralston\Tailpdf\Facades\TailPdf;
// Get raw PDF bytes for custom handling
$pdfContent = TailPdf::view('certificates.show', ['certificate' => $cert])
->pdf()
->raw();
// Attach to email, upload to S3, etc.
Mail::to($user)->send(new CertificateMail($pdfContent));
What You Get
- No maintenance - We handle Chrome, you handle your app
- Consistent output - Same PDF every time, no environment differences
- Full Tailwind support - Every utility class, including arbitrary values
- CSS Grid & Flexbox - Modern layouts render perfectly
- Async generation - Process large batches without blocking
- Fast response - Average 400ms, with CSS caching for repeat requests
Free your Forge server from Chrome. Let TailPDF handle the heavy lifting.
Ready to simplify PDF generation?
Start generating beautiful PDFs in minutes. No Chrome installation, no server configuration.
No credit card required • 100 free PDFs/month