PDFLib
PDFLib copied to clipboard
GPL Ghostscript 9.52: Unrecoverable error, exit code 1
this is result of running following php sample codes in command line
$pdflib = new ImalH\PDFLib\PDFLib();
$pdflib->setPdfPath('./sample.pdf');
$pdflib->setOutputPath('./images/');
$pdflib->setImageFormat(\ImalH\PDFLib\PDFLib::$IMAGE_FORMAT_PNG);
$pdflib->setDPI(96);
$pdflib->setPageRange(1,$pdflib->getNumberOfPages());
$pdflib->setFilePrefix('page-'); // Optional
$pdflib->convert();
GPL Ghostscript 9.52: Unrecoverable error, exit code 1
error is for running getNumberOfPages
method
sample.pdf
is near to php file and there is an images
folder there
pdf file is an standard pdf file and is converted before with other pdf to image php classes like https://github.com/spatie/pdf-to-image
hmm.. will have to look into, @mablae do you think you can check this issue ?
I modified this library for me.
public function getNumberOfPages(){ if($this->number_of_pages == -1){ if($this->gs_command == "gswin32c.exe" || $this->gs_command == "gswin64c.exe"){ $this->pdf_path = str_replace('\', '/', $this->pdf_path); $delimiter = "/"; $exit=preg_split("/".$delimiter."([^".$delimiter."]+)$/", $this->pdf_path,-1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); $ex="--permit-file-read=".$exit[0]."/"; } $pages = $this->executeGS('-q '.$ex.' -dNODISPLAY -c "('.$this->pdf_path.') (r) file runpdfbegin pdfpagecount = quit"',true); $this->number_of_pages = intval($pages); } return $this->number_of_pages; }
I'm running into the same problem. Have you had time to look at this?