vivutio / pdf-scribe-bundle
Symfony 7/8 bundle for PDF generation using Chrome Headless
Package info
github.com/vivutio/pdf-scribe-bundle
Type:symfony-bundle
pkg:composer/vivutio/pdf-scribe-bundle
v0.1.0-alpha
2026-02-01 22:14 UTC
Requires
- php: >=8.2
- symfony/config: ^7.0|^8.0
- symfony/dependency-injection: ^7.0|^8.0
- symfony/http-kernel: ^7.0|^8.0
- symfony/process: ^7.0|^8.0
This package is auto-updated.
Last update: 2026-03-29 22:31:42 UTC
README
A Symfony 7/8 bundle for generating PDFs using Chrome Headless. Provides excellent CSS support with the modern Chrome rendering engine.
Installation
composer require vivutio/pdf-scribe-bundle
Configuration
Create config/packages/pdf_scribe.yaml:
pdf_scribe: binary_path: '%env(PDF_SCRIBE_BINARY)%' timeout: 120 options: print-background: true no-pdf-header-footer: true
Add to .env:
# macOS PDF_SCRIBE_BINARY="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" # Linux PDF_SCRIBE_BINARY=/usr/bin/chromium-browser
Usage
use Vivutio\PdfScribeBundle\Contract\PdfGeneratorInterface; class InvoiceController extends AbstractController { public function download(Invoice $invoice, PdfGeneratorInterface $pdf): Response { $html = $this->renderView('invoice/pdf.html.twig', [ 'invoice' => $invoice, ]); $content = $pdf->fromHtml($html); return new Response($content, 200, [ 'Content-Type' => 'application/pdf', 'Content-Disposition' => 'attachment; filename="invoice.pdf"', ]); } }
API
PdfGeneratorInterface
fromHtml(string $html, array $options = []): string- Generate PDF from HTML stringfromUrl(string $url, array $options = []): string- Generate PDF from URLsaveFromHtml(string $html, string $outputPath, array $options = []): void- Save PDF from HTML to filesaveFromUrl(string $url, string $outputPath, array $options = []): void- Save PDF from URL to file
Options
| Option | Type | Description |
|---|---|---|
print-background |
bool | Print background graphics |
no-pdf-header-footer |
bool | Remove default header/footer |
landscape |
bool | Landscape orientation |
scale |
float | Scale factor (0.1 to 2.0) |
CSS @page Rules
Control page size and margins via CSS in your HTML template:
@page { size: A4; margin: 15mm; } @media print { body { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }
License
MIT