0

I am using GhostScript with C# and it is working fine but Don't know why with some specific PDF files it is not working. And I looked in GhostScript api and I found that only issue occurring with the last page of this PDF file Click here to Download.

GhostScript Runtime Version : v4.0.30319

GhostScript Version : 1.2.0.0

Error point in Ghostscript API as below lines.

public int Execute(string[] args)
{
    //Some Coding lines here

    // call ghostscript
    try
    {
        //This is the Error line on ghostscript api call
        result = NativeMethods.gsapi_init_with_args(_ghostScriptInstance, args.Length, _argumentPointersHandle.AddrOfPinnedObject());
    }
    finally
    {
        this.FreeHandles();
    }

    if (result < (int)ErrorCode.Success)            // TODO: often if GhostScript fails because you've passed the wrong combination of params etc, it still returns zero... unhelpful
        throw new GhostScriptException(result, args);

    return result;
}

Always getting -100 as error code. And Error Image as follow.

enter image description here

HABJAN
  • 9,212
  • 3
  • 35
  • 59
Govinda Rajbhar
  • 2,926
  • 6
  • 37
  • 62
  • What do you mean by "it doesn't work for some pdf files", does it give an error message, if yes what does it say ? does the output not look like expected, if yes in what way? – Stefan Hegny Dec 06 '16 at 14:06
  • @StefanHegny Please check now I have added error Image. And yes it is always creating issue with specific file as I have mention above and given its link also. – Govinda Rajbhar Dec 06 '16 at 14:32
  • It would be helpful to see the actual ghostscript error message, could you try running gs (gswin64 on win 64 e.g.) directly on the pdf? – Stefan Hegny Dec 06 '16 at 15:37
  • And the Ghostscript version is wrong, possibly that's the version of Ghostscript sharp or Ghostscript.NET. There never was a Ghostscript 4.0.30319 or 1.2.0.0. THe current version of Ghostscritp is 9.20. – KenS Dec 06 '16 at 16:57
  • Also an example PDF would be useful, as well as the actual Ghostscript command line equivalent of the program code. Forget that, I see the PDF file now. – KenS Dec 06 '16 at 16:58
  • Running the file here throws a warning about the Indexed colour space not being correct (lookup table is too short) but does not throw an error. You really need to find the version of Ghostscript you are using. You haven't given any real information as to the arguments you are passing so its kind of difficult to help. – KenS Dec 06 '16 at 17:01
  • @KenS: I believe 4.0.30319 is .NET framework runtime version (not Ghostscript as stated). The other thing why I wanted to say is that he is not using Ghostscript.NET. – HABJAN Dec 07 '16 at 09:02

0 Answers0