Hello everyone.
In this example, I am trying to show that by using GhostScript(version 9.01) exe we can convert a pdf file to a series of images.
For this code to run, the ghost script needs to be installed on your pc.
You can download the ghostscript binaries i.e. exe files (32-bit or 64-bit) from link
Steps to convert pdf to images using GhostScript:
1) Create a new console application in Visual Studio 2010.

2) Copy the below code into your application
using System.Diagnostics;
namespace PdfToImage
{
class Program {
public static void PdfToJpg(string ghostScriptPath, string input, string output)
{
string ars = "-dNOPAUSE -sDEVICE=jpeg -r300 -o" + output + "-%d.jpg " + input;
Process proc = new Process();
proc.StartInfo.FileName = ghostScriptPath;
proc.StartInfo.Arguments = ars;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
proc.Start();
proc.WaitForExit();
}
static void Main(string[] args)
{
string ghostScriptPath = @"C:\Program Files\gs\gs9.01\bin\gswin32.exe";
string inputFileName = @"C:\Users\Ahmed\Desktop\AISB08.pdf";
string outputFileName = @"E:\test";
PdfToJpg(ghostScriptPath, inputFileName, outputFileName);
}
}
}
Where,
ghostScriptPath: Refers to the full path of the exe file
input: Refers to the full path of the pdf file to convert.
Output: Refers to the full path of the image file name.

3) Set the output type of your console application to “Windows Application”.

That’s it. Your series of images of pdf will be stored at the given location. I have attached the sample application. this sample application will run only after installing Ghostscript (of desired version)
PdfToImage.rar (27.59 kb)
8f6b9dfd-6725-4de5-8837-d0d72c69dd39|1|5.0
Categories:
C#, GhostScript
15. November 2011
Tags:
Pdf to Image, GhostScript, C#