0
votes

Here is the exception trace:

Postscript delegate failed `[ghostscript library 8.70] -sstdout=%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pngalpha' -dTextAlphaBits=4 -dGraphicsAlphaBits=4 '-r72x72' '-sOutputFile=/tmp/magick-17649SdGWHr3z3794%d' '-f/tmp/magick-17649w9uyEgynEd2e' '-f/tmp/magick-17649t0lFMpipemUo'': Error: /typecheck in --run-- Operand stack: --dict:11/11(L)-- --dict:11/11(L)-- --dict:11/11(L)-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- Execution stack: %interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1862 1 3 %oparray_pop 1861 1 3 %oparray_pop 1845 1 3 %oparray_pop --nostringval-- --nostringval-- 2 1 1 --nostringval-- %for_pos_int_continue --nostringval-- --nostringval-- --nostringval-- --nostringval-- %array_continue --nostringval-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- Dictionary stack: --dict:1142/1684(ro)(G)-- --dict:1/20(G)-- --dict:75/200(L)-- --dict:75/200(L)-- --dict:106/127(ro)(G)-- --dict:286/300(ro)(G)-- --dict:22/25(L)-- --dict:4/6(L)-- --dict:25/40(L)-- Current allocation mode is local GPL Ghostscript 8.70: Unrecoverable error, exit code 1 @ error/ghostscript-private.h/InvokeGhostscriptDelegate/171

This is my php for

if (file_exists($pdf_path)) {
    try {
        $image = new Imagick($pdf_path);
        $image->readImage($pdf_path);
        $totalPage = $image->getNumberImages();
    } catch (ImagickException $e) {
        throw $e;
    }
}

Any idea would be appreciate

1

1 Answers

1
votes

It looks like this type of error occurs when the PDF is not quite valid, judging by some similar bug reports:

You can probably confirm that by using an online PDF validator like this one:

https://www.pdf-online.com/osa/validate.aspx

Exactly what to do about it if it is invalid isn't obvious. If the PDF is being generated by something under your control, you could fix whatever is generating an invalid PDF. If it's a user-supplied file, you could try repairing it with something like: https://pdf.recoverytoolbox.com/