phumtech/laravel-pdf-compress
最新稳定版本:v1.0.3
Composer 安装命令:
composer require phumtech/laravel-pdf-compress
包简介
Professional Laravel package to compress and optimize PDF files using qpdf and Ghostscript binaries.
README 文档
README
High-Performance, SEO-Optimized PDF Optimization for Laravel
Laravel PDF Compress is a professional-grade package designed to reduce and optimize PDF file sizes seamlessly. By leveraging powerful system-level binaries like qpdf and Ghostscript, it achieves compression ratios that native PHP libraries simply cannot reach.
✨ Features
- Dual-Engine Support: Harness the power of
qpdffor structural optimization andGhostscriptfor maximum file size reduction. - Intelligent Auto-Detection: Automatically finds binaries in your system PATH or local project folders.
- Bundled Binary Ready: Support for portable binaries (ideal for shared hosting or Windows environments).
- Fluent API: Clean, chainable syntax that follows Laravel best practices.
- Laravel Storage Integration: Works out-of-the-box with
Local,S3, and other custom disks. - Memory Efficient: Executes via
Symfony/Process, preventing PHP memory limit issues even with massive PDFs. - Quality Presets: Ready-to-use
low,balanced, andhighmodes.
🛠 Requirements
- PHP 8.1 or higher
- Laravel 10.x, 11.x, or 12.x
- System binaries: qpdf and/or Ghostscript
📦 Installation
composer require phumtech/laravel-pdf-compress
⚙️ System Binary Setup
This package requires underlying binaries to function. You have two ways to set them up:
1. System-Wide Installation (Recommended)
- Ubuntu/Debian:
sudo apt install qpdf ghostscript - MacOS:
brew install qpdf ghostscript - Windows: Download and add the
binfolders to your system PATH.
2. Bundled Binaries (Portable)
If you cannot install binaries system-wide (e.g., shared hosting), simply place the binary folders in your project root. The package will automatically scan for:
qpdf_*(e.g.,qpdf_12.3.2/bin/qpdf.exe)gs*(e.g.,gs10.03.0/bin/gswin64c.exe)bin/qpdforbin/gs
📖 Usage
Basic Compression
Automatically selects the best available driver:
use PhumTech\PdfCompress\Facades\PdfCompress; $result = PdfCompress::input('document.pdf') ->output('optimized.pdf') ->compress(); echo "Reduced by: {$result->percentage}%";
Using Laravel Storage
$result = PdfCompress::storage('reports/july.pdf') ->disk('s3') ->quality('high') ->compress();
Advanced Configuration
PdfCompress::input('original.pdf') ->driver('ghostscript') // 'qpdf' or 'ghostscript' ->quality('low') // 'low', 'balanced', 'high' ->overwrite() // Overwrite input file ->compress();
⚙️ Configuration
Publish the config file to customize paths and presets:
php artisan vendor:publish --tag="pdfcompress-config"
In config/pdfcompress.php, you can define custom binary paths and DPI settings.
🧪 Testing
composer test
🤝 Contributing
Please see CONTRIBUTING.md for details.
📄 License
The MIT License (MIT). Please see License File for more information.
Copyright (c) 2026 PhumTech.
phumtech/laravel-pdf-compress 适用场景与选型建议
phumtech/laravel-pdf-compress 是一款 基于 HTML 开发的 Composer 扩展包,目前已累计 4 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「pdf」 「compressor」 「compress」 「files」 「laravel」 「optimize」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 phumtech/laravel-pdf-compress 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 phumtech/laravel-pdf-compress 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 phumtech/laravel-pdf-compress 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CSS/Javascript Minificator, Compressor and Concatenator for TYPO3 - highly configurable frontend asset optimization for CSS/JS merging, minification and compression with optional body parsing, async/defer loading, inline output, data-ignore exclusions, SRI integrity validation/calculation, external
OriginPHP Html
YUI Compressor fork
PHP client for the Google Closure Compiler API in one file.
PHP performance tool analyser your script on time, memory usage and db query. Support Laravel and Composer for web, web console and command line interfaces.
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 39
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-28