timbogdanov/bolt-pdf

There is no license information available for the latest version (v1.0.7) of this package.

High-performance Laravel Blade-to-PDF package using headless Chrome

v1.0.7 2025-03-22 02:17 UTC

This package is auto-updated.

Last update: 2025-05-22 02:54:36 UTC


README

Blade-to-PDF rendering for Laravel 10/11/12+ using Headless Chrome โ€” supports full CSS3, JS, modern layouts, headers, footers, watermarks, and more.

Built with ๐Ÿ’ช performance, ๐Ÿง  modern standards, and ๐Ÿ–ค Laravel elegance.

โœจ Features

  • ๐Ÿงพ Convert any Blade view to a high-fidelity PDF
  • ๐ŸŽจ Supports modern CSS3: flexbox, grid, custom fonts
  • ๐Ÿง  Executes JavaScript: charts, animations, etc.
  • ๐Ÿงข Add headers, footers, and watermark overlays
  • ๐ŸงŠ Save, stream, download, or cache PDFs
  • ๐Ÿ”„ Supports queued generation for large documents
  • ๐Ÿ”ง Fully configurable, extensible & testable

๐Ÿš€ Installation

composer require timbogdanov/bolt-pdf
If using Laravel < 5.5, register the service provider and facade manually in config/app.php. Otherwise, auto-discovery will handle it.

Publish the config:

bash
Copy
Edit
php artisan vendor:publish --tag=config
โš™๏ธ Configuration
In .env:

env
Copy
Edit
BOLT_PDF_CHROME_PATH=/usr/bin/google-chrome
BOLT_PDF_TIMEOUT=30
In config/boltpdf.php, you can customize default margins, paper size, etc.

๐Ÿง‘โ€๐Ÿ’ป Usage
From a Blade view:
php
Copy
Edit
use BoltPdf\Facades\BoltPdf;

return BoltPdf::view('pdf.invoice', ['invoice' => $invoice])
              ->format('A4')
              ->landscape()
              ->header('<div>My Header</div>')
              ->footer('<div>Page <span class="pageNumber"></span></div>')
              ->watermark('CONFIDENTIAL')
              ->download('invoice.pdf');
Save to storage:
php
Copy
Edit
BoltPdf::view('pdf.report', $data)
       ->save('reports/weekly.pdf');
Queue generation (for large files):
php
Copy
Edit
GeneratePdfJob::dispatch('pdf.report', $data, 'reports/big.pdf');
๐Ÿ“‚ API Reference
Method	Description
view($blade, $data)	Load a Blade view
html($html)	Load raw HTML content
format('A4')	Set paper format
landscape()	Switch to landscape mode
timeout(30)	Set render timeout (in seconds)
header($html)	Add header HTML
footer($html)	Add footer HTML
watermark($text)	Add watermark text
stream($filename)	Stream PDF in browser
download($filename)	Force download of the PDF
save($path)	Save to local or cloud storage
output()	Return raw PDF content (binary)
๐Ÿงช Testing
bash
Copy
Edit
php artisan test
Or with PHPUnit:

bash
Copy
Edit
./vendor/bin/phpunit
๐Ÿงฉ Roadmap
 Headers & footers
 Watermark overlay
 Queued job support
 Blade directive: @pdf
 Caching support (->cache('key'))
 Chrome process pooling
๐Ÿ›ก Requirements
PHP 8.1+
Laravel 10/11/12+
Chrome or Chromium installed locally (/usr/bin/google-chrome or path in config)
โค๏ธ Credits
Built by Tim Bogdanov.
Powered by chrome-php/chrome and the Laravel ecosystem.

๐Ÿ“„ License
MIT ยฉ 2025

yaml
Copy
Edit

---

Let me know if youโ€™d like a logo, docs site scaffold, or a publish-to-Packagist checklist!