PHPackages                             pvtl/pvtl-pdf-optimisation - 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. pvtl/pvtl-pdf-optimisation

ActiveWordpress-plugin

pvtl/pvtl-pdf-optimisation
==========================

A WordPress plugin that optimises uploaded PDFs with Ghostscript and optional qpdf linearization, including batch compression tools for the media library.

00PHP

Since Jul 31Pushed yesterdayCompare

[ Source](https://github.com/pvtl/pvtl-pdf-optimisation)[ Packagist](https://packagist.org/packages/pvtl/pvtl-pdf-optimisation)[ RSS](/packages/pvtl-pvtl-pdf-optimisation/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

PVTL PDF Optimisation
=====================

[](#pvtl-pdf-optimisation)

A WordPress plugin that optimises uploaded PDF files with Ghostscript, with optional qpdf linearization, and provides batch compression tools for existing Media Library PDFs.

Why we created this plugin
--------------------------

[](#why-we-created-this-plugin)

PDF uploads are often much larger than they need to be for web delivery. Large files slow down page loads, consume storage, and make downloads slower for visitors. Manually compressing every PDF before upload is easy to forget, and existing Media Library files are rarely revisited.

We created PVTL PDF Optimisation to:

- **Automatically compress PDFs on upload** so new files are smaller without a manual step.
- **Reduce storage and bandwidth usage** for sites that host many documents.
- **Make existing PDFs easy to clean up** with a Tools admin page that compresses Media Library PDFs in safe batches.
- **Support CLI workflows** so individual files can be optimised outside the admin UI.

What this plugin does
---------------------

[](#what-this-plugin-does)

- **Optimises PDFs on upload** – When a PDF is uploaded, Ghostscript compresses it using a configurable quality preset (default: `ebook`). If qpdf is available, the result is also linearized for faster web viewing.
- **Keeps the original when compression does not help** – The original file is only replaced when the optimised version is smaller.
- **Batch-compresses existing Media Library PDFs** – Tools → PDF Optimisation processes attachments in batches and reports progress, savings, and errors.
- **Supports WP-CLI** – Optimise a single PDF path with `wp pvtl pdf-optimise `.
- **Logs activity** – Writes optimisation events to `logs/pvtl-pdf-optimisation.log` for troubleshooting.

The plugin does **not**:

- Change non-PDF uploads.
- Replace a PDF when Ghostscript produces a larger or equal-sized file.
- Require qpdf (Ghostscript alone is enough; qpdf linearization is optional when installed).

How it works
------------

[](#how-it-works)

1. **On upload**, the plugin hooks into `wp_handle_upload`. If the file is a PDF and required binaries are available, it compresses the file with Ghostscript and optionally linearizes it with qpdf, then replaces the upload only when the result is smaller.
2. **On the Tools page** (Tools → PDF Optimisation), an admin can start a batch job that walks PDF attachments in groups of 10, showing progress and total bytes saved.
3. **Via WP-CLI**, a single file path (absolute, or relative to the uploads directory) can be optimised with the same pipeline.

Compression quality is controlled by the Ghostscript PDFSETTINGS preset. The default is `ebook`. Override it with the `PVTL_PDF_OPTIMISATION_PRESET` constant or the `pvtl_pdf_optimisation_preset` filter. Allowed values: `screen`, `ebook`, `printer`, `prepress`.

Requirements
------------

[](#requirements)

- WordPress (uses standard upload, admin, AJAX, and WP-CLI APIs).
- PHP 8.3 or newer.
- **Ghostscript** (`gs`) available on the server `PATH` (required).
- **qpdf** available on the server `PATH` (optional; enables linearization).

Installation
------------

[](#installation)

### Composer / Wordpress Bedrock

[](#composer--wordpress-bedrock)

```
composer require pvtl/pvtl-pdf-optimisation
```

### Manual

[](#manual)

1. Upload plugin to `app/plugins/pvtl-pdf-optimisation/`
2. Activate plugin in WordPress admin
3. Ensure `gs` (and optionally `qpdf`) are installed on the server

Author
------

[](#author)

Pivotal Agency Pty Ltd

License
-------

[](#license)

MIT

###  Health Score

21

—

LowBetter than 17% of packages

Maintenance65

Regular maintenance activity

Popularity0

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 50% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/b54f3e43a9171099a685589c94f7cd35da4da8e600d5737536d14918d872ca56?d=identicon)[pvtl](/maintainers/pvtl)

---

Top Contributors

[![erinwelch](https://avatars.githubusercontent.com/u/53369160?v=4)](https://github.com/erinwelch "erinwelch (1 commits)")[![Pivotal-Dev-Server](https://avatars.githubusercontent.com/u/64242477?v=4)](https://github.com/Pivotal-Dev-Server "Pivotal-Dev-Server (1 commits)")

### Embed Badge

![Health badge](/badges/pvtl-pvtl-pdf-optimisation/health.svg)

```
[![Health](https://phpackages.com/badges/pvtl-pvtl-pdf-optimisation/health.svg)](https://phpackages.com/packages/pvtl-pvtl-pdf-optimisation)
```

PHPackages © 2026

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