mostafaznv/pdf-optimizer
Optimize and compress PDFs in PHP or Laravel using Ghostscript. Fluent API with extensive option support, logging, and customization. Works with file paths, UploadedFile, and storage disks, with optional queue support for async optimization.
Integrate a custom logger into the pdf-optimizer package using the logger method. This empowers you to capture detailed logs and gain insights into the optimization process, aiding in debugging and monitoring.
A logger, is a class that implements Psr\Log\LoggerInterface, utilized for logging activities. A recommended logging library that fully complies with this interface is Monolog. The pdf-optimizer package utilizes the logger to record information such as the Optimizers used, executed commands, and their respective outputs in the log files.
{% tabs %} {% tab title="Standalone PHP" %}
use App\Logger;
use Mostafaznv\PdfOptimizer\PdfOptimizer;
$logger = new Logger;
PdfOptimizer::init()->logger($logger)->optimize('input.pdf', 'output.pdf');
{% endtab %}
{% tab title="Laravel" %}
use App\Logger;
use Mostafaznv\PdfOptimizer\Laravel\Facade\PdfOptimizer;
PdfOptimizer::open('input-1.pdf')
->logger(new Logger)
->optimize('output-1.pdf');
{% endtab %} {% endtabs %}
How can I help you explore Laravel packages today?