Wednesday, May 8, 2024
HomePHPSimply Optimize PDFs in Laravel with the Optimizer Package deal

Simply Optimize PDFs in Laravel with the Optimizer Package deal


This PDF Optimizer bundle for PHP and Laravel functions for easy optimization and compression of PDF recordsdata. PDF Optimizer makes use of Ghostscript to considerably cut back PDF file sizes. The PDF Optimizer bundle can be utilized in any PHP mission but additionally affords Laravel-specific APIs that streamline working with PDF file optimization:

use MostafaznvPdfOptimizerLaravelFacadePdfOptimizer;

use MostafaznvPdfOptimizerEnumsColorConversionStrategy;

use MostafaznvPdfOptimizerEnumsPdfSettings;

 

$end result = PdfOptimizer::fromDisk('native')

->open('input-1.pdf')

->toDisk('s3')

->settings(PdfSettings::SCREEN)

->colorConversionStrategy(

ColorConversionStrategy::DEVICE_INDEPENDENT_COLOR

)

->colorImageResolution(50)

->optimize('output-1.pdf');

 

 

dd($end result->standing, $end result->message);

One other helpful Laravel-specific function is the power to queue the optimization of your recordsdata:

use MostafaznvPdfOptimizerLaravelFacadePdfOptimizer;

 

$end result = PdfOptimizer::fromDisk('minio')

->open('enter.pdf')

->toDisk('recordsdata')

->onQueue()

->optimize('output.pdf');

Different key options this bundle affords:

Fluent Methodology Chaining: Expertise the magnificence of a fluent and expressive API that seamlessly optimizes PDF recordsdata. Harness the facility of almost all Ghostscript choices with ease.

Logger Help: Seize detailed logs to achieve profound insights into the intricacies of the optimization course of. Keep knowledgeable and in management with the built-in logger.

Customization: Tailor the optimization course of to your precise wants. pdf-optimizer supplies a customizable resolution, permitting you to fine-tune your PDF optimization expertise.

Laravel Integration: Particularly designed for Laravel functions, pdf-optimizer helps numerous enter strategies, together with file paths, UploadedFile cases, and disk storage. This ensures flexibility and user-friendly integration throughout the Laravel ecosystem.

Queue Help: Elevate your optimization course of with asynchronous PDF file optimization utilizing Laravel queues. pdf-optimizer seamlessly integrates with Laravel’s queue system, making certain environment friendly background processing.

You will get began with this bundle by trying out the official PDF Optimizer documentation; the supply code can be obtainable on GitHub at mostafaznv/pdf-optimizer.



RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments