Page 1 of 1

ImageMagick.MagickDelegateErrorException

Posted: 2017-06-09T00:48:56-07:00
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 - 7.0.5.900
.Net framework - 4.5

Thanks in Advance,
Hari

Re: ImageMagick.MagickDelegateErrorException

Posted: 2017-06-09T01:57:37-07:00
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?

Re: ImageMagick.MagickDelegateErrorException

Posted: 2017-06-09T08:36:55-07:00
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.