PDFLib icon indicating copy to clipboard operation
PDFLib copied to clipboard

GPL Ghostscript 9.52: Unrecoverable error, exit code 1

Open imansa opened this issue 4 years ago • 4 comments

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

imansa avatar Sep 03 '20 06:09 imansa

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

imansa avatar Sep 03 '20 06:09 imansa

hmm.. will have to look into, @mablae do you think you can check this issue ?

imalhasaranga avatar Sep 07 '20 07:09 imalhasaranga

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; }

Fegra avatar Dec 04 '20 14:12 Fegra

I'm running into the same problem. Have you had time to look at this?

yannickl88 avatar Apr 22 '21 20:04 yannickl88