phumtech/laravel-pdf-compress 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

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

Latest Version on Packagist Laravel Version Support PHP Version Support License

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 qpdf for structural optimization and Ghostscript for 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, and high modes.

🛠 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 bin folders 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/qpdf or bin/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.

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: HTML

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固