You do not need to add a link to the DLL for your project. First, download the gs910w32.exe application file, then install it on your local computer. Get the location of the installed .exe file for example: -
"C: \ Program Files (x86) \ gs \ gs8.64 \ bin \ gswin32.exe"
use it in your c # application like:
private void PdfToJpg(string inputPDFFile, string outputImagesPath) { string ghostScriptPath = @"C:\Program Files (x86)\gs\gs8.64\bin\gswin32.exe"; String ars = "-dNOPAUSE -sDEVICE=jpeg -r102.4 -o" + outputImagesPath + "%d.jpg -sPAPERSIZE=a4 " + inputPDFFile; 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(); }
If your input PDF file name has spaces, you need to change the argument to
String ars = "-dNOPAUSE -sDEVICE=jpeg -r102.4 -o" + outputImagesPath + "%d.jpg -sPAPERSIZE=a4 " +"\"" + inputPDFFile + "\"";
you can specify the aspect ratio of the output image in the argument with the -r flag. If you use "-r300", the image width will be 3000 pixels and the height will change accordingly, from the above argument you will get an image with a size from 1024 to 768 pixels.
source share