[UPDATED: 2016-11-11] Fatal error: Uncaught exception ImagickException with message PDFDelegateFailed

QuestionsCategory: PDF Light Viewer[UPDATED: 2016-11-11] Fatal error: Uncaught exception ImagickException with message PDFDelegateFailed
supportsupport asked 1 year ago

Some of our users faced the following issue:

Fatal error: Uncaught exception 'ImagickException' with message 'PDFDelegateFailed `[ghostscript library] -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" "-sOutputFile=/tmp/magick-851228kWSnAgvIDd9K%d" "-f/tmp/magick-85122827Xrr11SLeoE" "-f/tmp/magick-851228amuGpSsk2mGx"': -dname= must be followed by a valid token @ error/pdf.c/InvokePDFDelegate/263' in /wp-content/plugins/pdf-light-viewer/controllers/PdfController.php:535

Stack trace: #0 /wp-content/plugins/pdf-light-viewer/controllers/PdfController.php(535): Imagick->readimage('/home/...')
#1 [internal function]: PdfLightViewer_PdfController::save_post(58)
#2 /wp-includes/plugin.php(525): call_user_func_array(Array, Array)
#3 /wp-content/plugins/pdf-light-viewer/controllers/PdfController.php on line 535

This issue could appear in situation, when you are trying to import newly created PDFs with old versions of Ghostscript, for example Ghostscript 8.70 which was released about 7 years ago! – in 2009-07-31 ( http://ghostscript.com/doc/current/History8.htm )

If you import PDF and see the described error, probably (but not definitely) your PDF contains some parts, formatting or content which were added to the format/specification after 2009.

And that’s probably the reason why you cannot convert this PDF. Though for more simple and/or old PDF Ghostscript 8.70 could work perfectly and because of that we do not limit Ghostscript requirements.

We could successfully import most test PDFs from our users with Ghostscript 9.18 (released in 2015).

Besides that’s the good practice to update software often for security reasons.

[UPDATED: 2016-11-11]

The issue not always in old Ghostscript. It could also be in old Imagick. In this case there is an alternative solution:

You can set your site to use Gmagick instead of Imagick (if it’s installed of course).
Change it in cPanel settings

After that make sure to switch libraries from ImageMagick to GraphicsMagick in the plguin’s settings

After that things should “just work” and you could try to re-import your PDF files.

 

Anyways if you have some questions please do not hesitate to ask us.