Error when trying to run a processor

Mar 11, 2014 at 6:24 PM
My intention is to convert a PDF to PNG, GhostscriptReasterizer first tried using the class and it worked correctly, but I can not set the output parameters all I wanted.

Then I took on the example of GhostscriptProcessor, but when I run it shows me an error "An error occured When call to 'gsapi_init_with_args' is made​​: -100".

This is the code:
        GhostscriptVersionInfo version = null;
        version = GhostscriptVersionInfo.GetLastInstalledVersion(GhostscriptLicense.GPL | GhostscriptLicense.AFPL, GhostscriptLicense.GPL);

        GhostscriptProcessor processor = new GhostscriptProcessor(version, false);

        processor.Processing += ShowStatus;
        processor.StartProcessing(GetArgs().ToArray(), null);
Arguments are defined in this function:
    IList<string> GetArgs()
    {
        IList<string> args = new List<string>();

        //args.Add("-dDOINTERPOLATE");
        //args.Add("-dGraphicsAlphaBits=4");
        //args.Add("-dDownScaleFactor=3");
        //args.Add("-dSAFER");
        //args.Add("-dBATCH");
        //args.Add("-dNOPAUSE");
        args.Add("-sDEVICE=pnggray");
        //args.Add("-r600");
        args.Add(string.Format("-otest.png");
        //args.Add("-q");
        args.Add("-f");
        args.Add(string.Format("test.pdf");
        return args;
    }
I tried different combinations, and I tried with Ghostscript command line app, with the same parameters:

gswin64c -sDEVICE=pnggray -otest.png -f test.pdf

And work fine.

Best Regards
Alejandro
Coordinator
Mar 12, 2014 at 7:44 AM
Hi Alejandro,

Try with this:
        private List<string> GetArgs()
        {
            List<string> args = new List<string>();
            args.Add("-empty"); // this one will not be used but it must be here
            args.Add("-sDEVICE=pnggray");
            args.Add(@"-oE:\gss_test\test.png");
            args.Add("-f");
            args.Add(@"E:\gss_test\test.pdf");
            return args;
        }
Make sure the full path is specified for both input and output file and the first switch is a dummy switch.

Cheers,
Josip
Mar 12, 2014 at 2:53 PM
Thanks Josip,

I did the test with the same parameters as you and it worked fine (good!).
I experimented with my modified code and failed (bad! :( ).

I checked, and the new problem is in the quotes used to avoid path with spaces.

example:

-o"c:\path\with spaces\file.png"

This causes the argument error.

For now I removed the quotes and I'll make sure not to have path with spaces, but I would like to know how you can fix that.

thank you very much
Alejandro
Coordinator
Mar 12, 2014 at 3:04 PM
Hi Alejandro,

You don't need quotes, simply set the folder after the switch as it is...

This works:
        private List<string> GetArgs()
        {
            List<string> args = new List<string>();
            args.Add("-empty"); // this one will not be used but it must be here
            args.Add("-sDEVICE=pnggray");
            args.Add(@"-oE:\folder with whitespaces\test.png");
            args.Add("-f");
            args.Add(@"E:\folder with whitespaces\test.pdf");
            return args;
        }
Cheers,
Josip
Marked as answer by adiazsanti on 3/12/2014 at 8:14 AM