0

I am printing a PDF file using the Ghostscript.NET wrapper. Printing is working fine but 2 blank pages appears before actual printing. Please can anyone help me? Am I doing anything wrong with following code? By the way, our printer is tiny and it is used to print barcodes.

Dim processor As Ghostscript.NET.Processor.GhostscriptProcessor = New Ghostscript.NET.Processor.GhostscriptProcessor()
        
Dim switches As List(Of String) = New List(Of String)
switches.Add("-empty")
switches.Add("-dPrinted")
switches.Add("-dBATCH")
switches.Add("-dNOPAUSE")
switches.Add("-dNOSAFER")
switches.Add("-dDEVICEHIGHTPOINTS=85")
switches.Add("-dDEVICEWIDTHPOINTS=90")
switches.Add("-dFIXEDMEDIA")
switches.Add("-dPDFFitPage")
switches.Add("-sDEVICE=mswinpr2")
switches.Add(Convert.ToString("-sOutputFile=%printer%") + _printerName)
switches.Add("-c")
switches.Add(_pdfFile)
processor.StartProcessing(switches.ToArray(), Nothing)
Andrew Morton
  • 24,203
  • 9
  • 60
  • 84
mesha
  • 31
  • 5

1 Answers1

0

I really doubt you want to put -c in your command line; that introduces a PostScript program sequence. Assuming that your file is a PDF file, you really don't want to do that. Even if it is a PostScript program, that will normally cause Ghostscript to treat the file name (not the contents) as a PostScript program, which I'd expect to produce an error.

And indeed, when I try that here from the command line it throws an error. I have no idea what effect that will have with Ghostscript.NET.

I'd suggest that you should not be using -dNOSAFER as that bypasses all the security. Of course, possibly you know the provenance of all the files you are printing, in which case it's safe. But still I can't see why you would use it.

halfer
  • 19,824
  • 17
  • 99
  • 186
KenS
  • 30,202
  • 3
  • 34
  • 51
  • Thank you. Unfortunately, this didn't worked though i removed -c and -dNOSAFER command. Always, i am getting 2 blank pages printing initially and then actual printing happening. Any alternative thoughts please? – mesha Aug 03 '20 at 10:39
  • Its hard to say since I don't have your printer, nor your PDF file to look at. – KenS Aug 03 '20 at 14:25