arrow_back
Back

Working with PDF files in PHP: OCR and PDF-to-image

Andrew Dorokhov Andrew Dorokhov schedule 1 min read
menu_book Table of Contents

OCR

PDF to image

$pdf = new Spatie\PdfToImage\Pdf(__DIR__ . '/document.pdf');

$pdf->setResolution(400);

// Required — the library doesn't infer it automatically.
$pdf->setOutputFormat('png');

$pdf->setCompressionQuality(100);

$png_file_path = __DIR__ . '/output.png';

$pdf->saveImage($png_file_path);
code

Need Help with Development?

Happy to help — reach out via the contacts or go straight to my Upwork profile.

work View Upwork Profile arrow_forward
Next Article

HTTP proxies for scraping: providers, testing, and PHP curl

arrow_forward