定制 timbogdanov/bolt-pdf 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

timbogdanov/bolt-pdf

最新稳定版本:v1.0.7

Composer 安装命令:

composer require timbogdanov/bolt-pdf

包简介

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

README 文档

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!

统计信息

  • 总下载量: 6
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2025-03-21