Magick.NET is an object-oriented C# interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick.NET
Posts: 5
Joined: 2017-06-09T00:24:58-07:00
Authentication code: 1151


Post by HariK »

Hi Team,

I am getting the following error - "An exception of type 'ImageMagick.MagickDelegateErrorException' occurred in Magick.NET-Q16-AnyCPU.dll but was not handled in user code Additional information: PDFDelegateFailed `The system cannot find the file specified. ' @ error/pdf.c/ReadPDFImage/793"

What I am trying to do:
1)Upload a pdf file hadrly of size 1 MB
2)Loop through each and every page of the PDF file and convert each page to a bitmap image
3)Then input the Bitmap image to the Tesseract for doing OCR

My piece of code:
public void SplitFile(string filePath)
ImageMagick.MagickReadSettings settings = new ImageMagick.MagickReadSettings();
settings.Density = new ImageMagick.Density(300, 300);

ImageMagick.MagickImageCollection images = new ImageMagick.MagickImageCollection();
images.Read(filePath, settings); // IN THIS lINE I AM GETTING THE ABOVE ERROR

for (int pageNumber = 0; i <= images.Count; i++)
bitmap = images[pageNumber].ToBitmap();
BitmapToPixConverter b = new BitmapToPixConverter();
Pix pix = b.Convert(bitmap);
ProcessOCR(pix, pageNumber);


Looking forward for some inputs on how to get rid of the above mention error.

Installed the following package from Nuget package manger - Imagick.NET-Q16-AnyCPU
Version -
.Net framework - 4.5

Thanks in Advance,

Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: ImageMagick.MagickDelegateErrorException

Post by snibgo »

Harik wrote:The system cannot find the file specified.
I suggest you printf the value of filePath. Does that file exist?

I also suggest you try the equivalent from the command line. Does that work?
snibgo's IM pages:

User avatar
Posts: 1625
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789

Re: ImageMagick.MagickDelegateErrorException

Post by dlemstra »

Did you install Ghostscript? You will need this to read PDF files. Be aware that you need a paid license when you want to use it in a commercial application.
.NET + ImageMagick = Magick.NET, @MagickNET, Donate