0


I'm using the GhostScript.NET.Processor dll to send a pdf to print from a web service. The code I'm trying to execute is:

ThreadPool.QueueUserWorkItem(Sub()

       Dim inputFile As String = "C:\WebServiceLog\checklist.pdf"
       Dim printerName As String = "MIAUMIAUMIAU"
       Using processor As New GhostscriptProcessor()
            Dim switches As New List(Of String)()
            switches.Add("-empty")
            switches.Add("-dPrinted")
            switches.Add("-dBATCH")
            switches.Add("-dNOPAUSE")
            switches.Add("-dNOSAFER")
            switches.Add("-dDuplex")
            switches.Add("-dTumble=0")
            switches.Add("-dNumCopies=1")
            switches.Add("-sDEVICE=mswinpr2")
            switches.Add(Convert.ToString("-sOutputFile=%printer%") & printerName)
            switches.Add("-f")
            switches.Add(inputFile)
            processor.StartProcessing(switches.ToArray(), Nothing)
         End Using
 End Sub)



The error that I keep getting is
An error occured when call to 'gsapi_new_instance' is made: -100

I am running 64bit. Any help on this issue would be greatly appreciated.

rmon2852
  • 220
  • 1
  • 7
  • 19
  • 1
    Possible duplicate of [What is causing Ghostscript to return an error of -100?](http://stackoverflow.com/questions/4340407/what-is-causing-ghostscript-to-return-an-error-of-100) – piaste May 31 '16 at 10:54

2 Answers2

0

-empty isn't a Ghostscript option (though it might be something to do with the .NET code, I wouldn't know).

The first thing I would do is try using Ghostscript from the command line with the exact same command line arguments, I would suggest this is more likely to tell you if anything is wrong. You should also check if Ghostscript sent anything to stderr or stdout (it almost certainly will have sent something, and you haven't quoted the output)

If that does fail, simplify the command line by either removing arguments one at a time until it works, or by reducing to the minimum and adding one at a time until it doesn't.

Note that many of the options you are supplying (eg -dTumble and -dDuplex) will have no effect whatever with the mswinpr2 device.

KenS
  • 30,202
  • 3
  • 34
  • 51
0

For future reference. It was IIS permissions. After I changed these to an account that had access to the printer everything worked fine.

rmon2852
  • 220
  • 1
  • 7
  • 19