PDF to Image

First of all you have download “GhostScript” from Here Installed it.

C#.net Code as below

1) Create a new console application in Visual Studio 2010.

2) Copy the below code into your application

public static void PdfToJpg(string ghostScriptPath,string input, string output)
{
//String ars = "-dNOPAUSE -sDEVICE=jpeg -r300 -o" + output + "-%d.jpg " + input;
 String ars = "-dNOPAUSE -sDEVICE=png16m -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r150*150 -o" + output + "-%d.png " + input; //all image generate with full clarity and same pixel size (1275*1650)
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()
}
 
Where,
ghostScriptPath: Refers to the full path of the exe file
input: Refers to the full path of the pdf file to covert.
Output: Refers to the full path of the image file name.
For eg.,
static void Main(string[] args)
{
string ghostScriptPath = @"D:\Program Files\gs\gs9.01\bin\gswin32.exe";
string inputFileName = @"C:\test.pdf";
string outputFileName = @"E:\New\test";
PdfToJpg(ghostScriptPath, inputFileName, outputFileName);
}
·       3)  Set the output type of your console application to “Windows Application”.
That’s it.
Share