mostafaznv/pdf-optimizer
Optimize and compress PDFs in PHP or Laravel using Ghostscript. Fluent, chainable API with rich options, logging, and customization. Laravel-friendly inputs (paths, uploads, disks) plus queue support for async optimization.
For scenarios where the existing configuration options may not cover your specific needs, the setExtraOptions method allows you to inject custom Ghostscript options directly into the optimization script. This flexibility ensures that no aspect of the optimization process is beyond your control.
{% tabs %} {% tab title="Standalone PHP" %}
use Mostafaznv\PdfOptimizer\PdfOptimizer;
PdfOptimizer::init()
->setExtraOptions([
'-dCustom1=true',
'-dCustom2=false'
])
->optimize('input.pdf', 'output.pdf');
{% endtab %}
{% tab title="Laravel" %}
use Mostafaznv\PdfOptimizer\Laravel\Facade\PdfOptimizer;
PdfOptimizer::open('input-1.pdf')
->setExtraOptions([
'-dCustom1=true',
'-dCustom2=false'
])
->optimize('output-1.pdf');
{% endtab %} {% endtabs %}
How can I help you explore Laravel packages today?