Search code examples
phppdflib

Specify image dimensions when creating PNGs from a PDF with pdflib


Can the dimensions of the PNGs created from this script be set?

e.g. setImageWidth = '200', setImageHeight ='500'

Is this possible with pdflib or should I use GD after initial images are created?

Could not find any answers in SO or Google on this using pdflib.

$pdflib = new ImalH\PDFLib\PDFLib();
$pdflib->setPdfPath($pdf_file_path);
$pdflib->setOutputPath($folder_path_for_images);
$pdfLib->setImageFormat(\ImalH\PDFLib\PDFLib::$IMAGE_FORMAT_PNG);   
$pdflib->setDPI(50);
$pdflib->setPageRange(1,$pdflib->getNumberOfPages());
$pdflib->convert(); 

Solution

  • They have a imagecropauto function that looks like the closest thing honestly:

    resource imagecropauto ( resource $image [, int $mode = -1 [, float $threshold = .5 [, int $color = -1 ]]] )