yassin/ypdf
Composer 安装命令:
composer require yassin/ypdf
包简介
Y-PDF: Headless browser PDF generator for Laravel supporting full HTML/CSS/JS stacks.
README 文档
README
A Laravel-ready package that uses a headless Chromium instance to render full HTML, CSS, JavaScript, Bootstrap, Tailwind, and jQuery experiences into pixel-perfect PDFs. Stop fighting traditional PHP PDF libraries that ignore styles — render the same markup your frontend already produces.
Highlights
- Uses chrome-php/chrome, so anything Chromium can paint (Vue, React, Livewire, Blade + Tailwind, etc.) will appear in the PDF.
- Simple API:
YPdf::renderFromView()andYPdf::renderFromHtml()return binary data or save directly to disk. - Configurable viewport, margins, background printing, sandbox flags, and custom wait strategies before capturing the PDF.
- Ships with a publishable config file so each project can point to its own Chromium binary, temp directory, and timeouts.
- Designed to live inside its own repository — drop this folder into a separate git repo, push to GitHub, and submit to Packagist. Afterwards, require it in any Laravel app with Composer.
Package Structure
packages/
└── imar/
└── ypdf/
├── composer.json
├── config/ypdf.php
├── src/
│ ├── Contracts/
│ ├── Drivers/
│ ├── Facades/
│ ├── YPdfManager.php
│ └── YPdfServiceProvider.php
└── README.md
Installation (after publishing to Packagist)
composer require yassin/ypdf
# Install the headless Chrome adapter only if you plan to use it
composer require chrome-php/chrome
php artisan vendor:publish --tag=ypdf-config
Want to write your own driver or call a remote rendering API instead? Set YPDF_DRIVER
to a custom driver name and bind an implementation of YPdf\Contracts\PdfEngine in a service
provider—no Chromium dependency required.
Ensure Chromium is installed on the server, or point HEADLESS_PDF_CHROME_BINARY to a bundled binary. Example .env entries:
YPDF_CHROME_BINARY=/usr/bin/google-chrome-stable
YPDF_TEMP=/var/tmp/ypdf
YPDF_NO_SANDBOX=true
Usage
use YPdf; // Render a Blade view straight to disk YPdf::renderFromViewToFile('pdfs.invoice', ['order' => $order], storage_path('app/pdfs/order.pdf')); // Grab the binary and stream it to the browser return response( YPdf::renderFromHtml($html), 200, ['Content-Type' => 'application/pdf'] );
Need to render an authenticated page? Generate a signed URL and call YPdf::renderFromUrl($url).
Roadmap
- Additional drivers (Playwright, remote rendering service)
- Queued rendering + retry helpers
- HTML pre-processors for asset inlining and critical CSS extraction
Contributions welcome once the package is in its own repository!
yassin/ypdf 适用场景与选型建议
yassin/ypdf 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 12 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 yassin/ypdf 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 yassin/ypdf 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 7
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-07