Ghostscript for extracting pdf to jpeg images

Oct 2, 2014 at 7:10 AM
ghost script gives me this exception when im trying to extract pdf file into jpeg images .

Ghostscript.NET.GhostscriptAPICallException: An error occured when call to 'gsapi_init_with_args' is made: -100
at Ghostscript.NET.Processor.GhostscriptProcessor.StartProcessing(String[] args, GhostscriptStdIO stdIO_callback)
at Ghostscript.NET.GhostscriptDevice.Process(GhostscriptVersionInfo ghostscriptVersion, Boolean fromMemory, GhostscriptStdIO stdIO_callback)
at Ghostscript.NET.GhostscriptDevice.Process()

at Archiving.Classes.ghostscript..ctor(String[] InputFiles, String MainFolder)

it works fine with no problem on the server , but the problem appears on real environments , ex. windows 7
Coordinator
Oct 3, 2014 at 8:46 AM
Hi,

Can I please see some code?

This only tells me that there is something wrong with the parameters you are passing to the GhostscriptProcessor.

Cheers,
Josip
Oct 8, 2014 at 8:12 AM
Hi,
yes of course .

PdfReader PDFReader = new PdfReader(InputPath);
            int PDFPageCount = PDFReader.NumberOfPages;
            GhostscriptJpegDevice dev = new GhostscriptJpegDevice(GhostscriptJpegDeviceType.Jpeg);
            dev.GraphicsAlphaBits = GhostscriptImageDeviceAlphaBits.V_4;
            dev.TextAlphaBits = GhostscriptImageDeviceAlphaBits.V_4;
            dev.InputFiles.Add(InputPath);

            for (int index = 1; index <= PDFPageCount; index++)
            {
                dev.Pdf.FirstPage = index;
                dev.Pdf.LastPage = (index + 1);
                dev.OutputPath = Path.Combine(ghostFile, Path.GetFileName(index.ToString()) + ".Jpeg");
                dev.Process();

                pathes.Add(Path.Combine(ghostFile, Path.GetFileName(index.ToString()) + ".Jpeg"));

            }
            PDFReader.Close();



Thank you,
Aziza