vivutio/pdf-scribe-bundle
Composer 安装命令:
composer require vivutio/pdf-scribe-bundle
包简介
Symfony 7/8 bundle for PDF generation using Chrome Headless
README 文档
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
vivutio/pdf-scribe-bundle 适用场景与选型建议
vivutio/pdf-scribe-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 29 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 01 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「bundle」 「pdf」 「headless」 「chrome」 「html-to-pdf」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 vivutio/pdf-scribe-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 vivutio/pdf-scribe-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 vivutio/pdf-scribe-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
2lenet/EasyAdminPlusBundle
The bundle for easy using json-rpc api on your project
Provide a way to secure accesses to all routes of an symfony application.
DMS Meetup API Bundle, enables Meetup API clients in services
Bundle Symfony DaplosBundle
Provides a Data Grid tables for your Symfony project.
统计信息
- 总下载量: 29
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 22
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-28