Note, though, that on a system with a windowed graphical user interface, it's common to use Ghostscript through a previewer, so you should read the section about previewers in the documentation for new users. Ghostscript is capable of interpreting PostScript, encapsulated PostScript (EPS), DOS EPS (EPSF), and - if the executable was built for it - Adobe Portable Document Format (PDF). Ghostscript reads PDF and PostScript as input, it doesn't read image formats, and in particular doesn't read TIFF. However PostScript is a programming language, so it is entirely possible to write a PostScript program to read a TIFF file (the viewgif.ps and viewjpeg.ps program supplied with Ghostscript do this for GIF and JPEG formats).
Convert PDF file to images using GhostScript in C#
Mar 03, 2011 02:13 AM|mahioak|LINK
Hello everyone.
This is my second thread, which might be useful for those looking for the way to convert PDF file to images.
In this example, I am using GhostScript(version 9.01) exe process to 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 below 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
![Use Ghostscript To Convert Pdf To Tiff Use Ghostscript To Convert Pdf To Tiff](http://cdn.ilovefreesoftware.com/wp-content/uploads/2011/12/Free-video-to-GIF-converter002_thumb.jpg)
publicstaticvoid PdfToJpg(string ghostScriptPath,string input, string output)
{
String ars = '-dNOPAUSE -sDEVICE=jpeg -r300 -o' + output + '-%d.jpg ' + input;
Process proc = newProcess();
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.,
staticvoid Main(string[] args)
{
string ghostScriptPath = @'D:Program Filesgsgs9.01bingswin32.exe';
string inputFileName = @'C:test.pdf';
string outputFileName = @'E:Newtest';
PdfToJpg(ghostScriptPath, inputFileName, outputFileName);
}
· 3) Set the output type of your console application to “Windows Application”.
That’s it.
Note:
If you want know more about the options and switches available for GhostScript, please refer the GhostScript Documentation.
Thanks & Regards
Mahendra