Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPL Ghostscript 9.52: Unrecoverable error, exit code 1 #19

Open
imansa opened this issue Sep 3, 2020 · 4 comments
Open

GPL Ghostscript 9.52: Unrecoverable error, exit code 1 #19

imansa opened this issue Sep 3, 2020 · 4 comments

Comments

@imansa
Copy link

imansa commented Sep 3, 2020

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
Copy link
Author

imansa commented Sep 3, 2020

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

@imalhasaranga
Copy link
Owner

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

@Fegra
Copy link

Fegra commented Dec 4, 2020

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

@yannickl88
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants