PHPackages                             phumtech/laravel-pdf-compress - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PDF &amp; Document Generation](/categories/documents)
4. /
5. phumtech/laravel-pdf-compress

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

phumtech/laravel-pdf-compress
=============================

Professional Laravel package to compress and optimize PDF files using qpdf and Ghostscript binaries.

v1.0.3(2mo ago)04MITPHP ^8.1

Since Apr 28Compare

[ Source](https://github.com/phumtech/laravel-pdf-compress)[ Packagist](https://packagist.org/packages/phumtech/laravel-pdf-compress)[ Docs](https://github.com/PhumTech/laravel-pdf-compress)[ RSS](/packages/phumtech-laravel-pdf-compress/feed)WikiDiscussions Synced 1mo ago

READMEChangelogDependencies (5)Versions (5)Used By (0)

🚀 Laravel PDF Compress
======================

[](#-laravel-pdf-compress)

### High-Performance, SEO-Optimized PDF Optimization for Laravel

[](#high-performance-seo-optimized-pdf-optimization-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/fbaa2cf5e67527507dc9446ec218830e07047bf847885b4e94358d8786d98225/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7068756d746563682f6c61726176656c2d7064662d636f6d70726573732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/phumtech/laravel-pdf-compress)[![Laravel Version Support](https://camo.githubusercontent.com/abc9468601680ca6b38556ae38a444b9031edffe5b0ad0acbe44e2b4c83d8906/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d3130253246313125324631322d7265642e7376673f7374796c653d666c61742d737175617265)](https://laravel.com)[![PHP Version Support](https://camo.githubusercontent.com/5b4efc369ce5323aa755ead39181d6fd48c65fa9af337baa841498eff964b101/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e312532422d3838393262662e7376673f7374796c653d666c61742d737175617265)](https://php.net)[![License](https://camo.githubusercontent.com/2e3b2249cfc0567422aaea6ef66a82ff1472d6c582083feffa3cf1bcd10775df/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7068756d746563682f6c61726176656c2d7064662d636f6d70726573732e7376673f7374796c653d666c61742d737175617265)](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
----------

[](#-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
--------------

[](#-requirements)

- **PHP** 8.1 or higher
- **Laravel** 10.x, 11.x, or 12.x
- System binaries: **qpdf** and/or **Ghostscript**

---

📦 Installation
--------------

[](#-installation)

```
composer require phumtech/laravel-pdf-compress
```

### ⚙️ System Binary Setup

[](#️-system-binary-setup)

This package requires underlying binaries to function. You have two ways to set them up:

#### 1. System-Wide Installation (Recommended)

[](#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)

[](#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
-------

[](#-usage)

### Basic Compression

[](#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

[](#using-laravel-storage)

```
$result = PdfCompress::storage('reports/july.pdf')
    ->disk('s3')
    ->quality('high')
    ->compress();
```

### Advanced Configuration

[](#advanced-configuration)

```
PdfCompress::input('original.pdf')
    ->driver('ghostscript') // 'qpdf' or 'ghostscript'
    ->quality('low')        // 'low', 'balanced', 'high'
    ->overwrite()           // Overwrite input file
    ->compress();
```

---

⚙️ Configuration
----------------

[](#️-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
---------

[](#-testing)

```
composer test
```

---

🤝 Contributing
--------------

[](#-contributing)

Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.

---

📄 License
---------

[](#-license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

Copyright (c) 2026 **PhumTech**.

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance83

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

86d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/690563?v=4)[MengDev](/maintainers/MengDev)[@mengdev](https://github.com/mengdev)

---

Top Contributors

[![phumtech](https://avatars.githubusercontent.com/u/274576137?v=4)](https://github.com/phumtech "phumtech (8 commits)")

---

Tags

laravelpdffilescompressorcompressghostscriptoptimizeroptimizeqpdfphumtech

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/phumtech-laravel-pdf-compress/health.svg)

```
[![Health](https://phpackages.com/badges/phumtech-laravel-pdf-compress/health.svg)](https://phpackages.com/packages/phumtech-laravel-pdf-compress)
```

###  Alternatives

[laravel/horizon

Dashboard and code-driven configuration for Laravel queues.

4.2k95.4M321](/packages/laravel-horizon)[spatie/laravel-health

Monitor the health of a Laravel application

87912.0M177](/packages/spatie-laravel-health)[rockett/weasyprint

A feature-rich WeasyPrint wrapper for generating PDFs from HTML and CSS, with support for PDF/A, PDF/UA, attachments, and optional Laravel integration.

30224.7k](/packages/rockett-weasyprint)[mostafaznv/pdf-optimizer

PDF optimization tool for PHP and Laravel applications

172166.2k](/packages/mostafaznv-pdf-optimizer)[pontedilana/php-weasyprint

PHP library allowing PDF generation from an url or a html page. Wrapper for Kozea/WeasyPrint.

791.2M18](/packages/pontedilana-php-weasyprint)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
