This project has moved and is read-only. For the latest updates, please go here.

PDFDelegateFailed - Unknown device: pamcmyk32

Sep 16, 2015 at 10:40 AM
I'm trying to convert a PDF to TIFF but I get the following exception when I try to read the PDF file:
An unhandled exception of type 'ImageMagick.MagickDelegateErrorException' occurred in Magick.NET.Wrapper-x86.dll

Additional information: MagickTest.vshost.exe: PDFDelegateFailed `[ghostscript library 8.61] -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pamcmyk32" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r300x300" -dUseCIEColor  "-sOutputFile=C:/Users/s44u3r/AppData/Local/Temp/magick-10984wkqj-iXpHBFv%d" "-fC:/Users/s44u3r/AppData/Local/Temp/magick-10984AiKiZFwuIAsw" "-fC:/Users/s44u3r/AppData/Local/Temp/magick-10984PjgBvWjAk2Gv"': Unknown device: pamcmyk32

Unrecoverable error: undefined in .uninstallpagedevice

Operand stack:

    defaultdevice

 @ error/pdf.c/InvokePDFDelegate/271
I have installed Ghostscript 8.71 and I'm using Visual Studio Express 2013 on Windows 7. Magick.NET is version 7.0.0.0018-Q16-x86.

This is my code:
MagickReadSettings settings = new MagickReadSettings();
            settings.Density = new PointD(300, 300);
            using (MagickImageCollection images = new MagickImageCollection())
            {
                // Add all the pages of the pdf file to the collection
                images.Read(fileInfo.FullName, settings);

                int page = 1;
                foreach (MagickImage image in images)
                {
                    image.Format = MagickFormat.Tiff;
                    image.Write(fileInfo.Directory.FullName + "\\MyImage.Page" + page + ".tif");
                    page++;
                }
            }
The exception occurs at the line images.Read().

The device in question (pamcmyk32) is available in my installation. I checked with the command gswin32.exe -h:
GPL Ghostscript 8.71 (2010-02-10)
Copyright (C) 2010 Artifex Software, Inc.  All rights reserved.
Usage: gs [switches] [file1.ps file2.ps ...]
Most frequently used switches: (you can use # in place of =)
 -dNOPAUSE           no pause after page   | -q       `quiet', fewer messages
 -g<width>x<height>  page size in pixels   | -r<res>  pixels/inch resolution
 -sDEVICE=<devname>  select device         | -dBATCH  exit after last file
 -sOutputFile=<file> select output file: - for stdout, |command for pipe,
                                         embed %d or %ld for page #
Input formats: PostScript PostScriptLevel1 PostScriptLevel2 PostScriptLevel3 PDF

Default output device: display
Available devices:
   bbox bit bitcmyk bitrgb bj10e bj200 bjc600 bjc800 bmp16 bmp16m bmp256
   bmp32b bmpgray bmpmono bmpsep1 bmpsep8 cdeskjet cdj550 cdjcolor cdjmono
   declj250 deskjet devicen display djet500 djet500c eps9high eps9mid epson
   epsonc epswrite ibmpro ijs jetp3852 jpeg jpegcmyk jpeggray laserjet lbp8
   lj250 ljet2p ljet3 ljet3d ljet4 ljet4d ljetplus m8510 mswindll mswinpr2
   necp6 nullpage pamcmyk32 pbm pbmraw pcx16 pcx24b pcx256 pcxcmyk pcxgray
   pcxmono pdfwrite pgm pgmraw pgnm pgnmraw pj pjxl pjxl300 pkmraw png16
   png16m png256 pngalpha pnggray pngmono pnm pnmraw ppm ppmraw ps2write
   psdcmyk psdrgb psmono pswrite pxlcolor pxlmono r4081 spotcmyk st800
   stcolor svg t4693d2 t4693d4 t4693d8 tek4696 tiff12nc tiff24nc tiff32nc
   tiff48nc tiff64nc tiffcrle tiffg3 tiffg32d tiffg4 tiffgray tifflzw
   tiffpack tiffsep tiffsep1 txtwrite uniprint
Search path:
   . ; C:\Program Files\ghostscript\gs8.71\lib ;
   C:\Program Files\ghostscript\fonts ; %rom%Resource/Init/ ; %rom%lib/ ;
   c:/gs/gs8.71/Resource/Init ; c:/gs/gs8.71/lib ;
   c:/gs/gs8.71/Resource/Font ; c:/gs/fonts
Initialization files are compiled into the executable.
For more information, see c:/gs/gs8.71/doc/Use.htm.
Please report bugs to bugs.ghostscript.com.
Any ideas what I'm doing wrong?
Sep 16, 2015 at 2:16 PM
Adding the line
MagickNET.SetGhostscriptDirectory("C:\\Program Files (x86)\\ghostscript\\gs8.71\\bin");
solved the problem.
Sep 16, 2015 at 2:45 PM
It found '[ghostscript library 8.61]' instead of 8.71 (first part of the exception). It seems you also have 8.61 installed but probably with a different architecture then your 8.71 version. Magick.NET tries to find a version that best matches your architecture and found version 8.61.
Sep 16, 2015 at 2:47 PM
Yes, I noticed the reference to 8.61. That's why I thought of setting the directory explicitely. It seems to be part of another software package on my machine.

Thanks.