How to convert PDF file pages to jpg image using imagemagick in asp.net

May 17, 2011 at 12:39 PM

Hi all,

How to use image magic to convert pdf to jpg image. I want to convert each page of pdf to am image.

Thanks.

Sandhya.

 

 

 

 

 

Jan 13, 2012 at 2:40 PM

Hi,

I'm guessing you won't get an answer now, but if you find out could you let me know please :0

Thanks

Jan 14, 2012 at 8:07 AM

There are two ways to convert a pdf to an image. You can either read all the images at once or just read one image. For this to work you need to have ghostscript installed.

using (ImageList imageList = new ImageList())
{
	imageList.ReadImages(inputFile);
	int pageIndex = 0;
	foreach (Image page in imageList)
	{
		page.Write(outputDirectory + "\\Page." + pageIndex + ".jpg");
		pageIndex++;
	}
}

using (Image firstPage = new Image())
{
	firstPage.Read(inputFile + "[0]");
	firstPage.Write(outputDirectory + "\\FirstPage.jpg");
}

Mar 22, 2012 at 1:10 PM

do i have to have the ghostscript dll in the project for it to work? It is installed on my machine, but I get an error when trying to add the dll to the project. And when trying to execute my project, getting a FileNotFoundException: "The specified module could not be found. (Exception from HRESULT: 0x8007007E)" when I try to execute.

Mar 24, 2012 at 6:10 PM

I was getting the same results until I rebooted by pc. After that everything worked as advertised.

May 22, 2014 at 2:40 AM
Or you can convert PDF to JPG this way.
Oct 7, 2015 at 7:42 AM
Can we convert it through image magik?