I'm trying to print a PDF document using ghostscript. I'm using the GHOSTPRINT.NET wrapper. I have been able to achieve sending output to the printer, however it remains stuck in spooling status. Not sure if it has to do with the switches I'm using or the file itself.. Any help would be appreciated. Here's the code:
public static void PrintFormPdfData(byte[] formPdfData, string printer)
{
string tempFile;
tempFile = Path.GetTempFileName();
using (FileStream fs = new FileStream(tempFile, FileMode.Create))
{
fs.Write(formPdfData, 0, formPdfData.Length);
fs.Flush();
}
using (GhostscriptProcessor processor = new GhostscriptProcessor())
{
List<string> switches = new List<string>();
switches.Add("-empty");
switches.Add("-dPrinted");
switches.Add("-dBATCH");
switches.Add("-dNOPAUSE");
switches.Add("-dNOSAFER");
switches.Add("-dNumCopies=1");
switches.Add("-sDEVICE=mswinpr2");
switches.Add("-sOutputFile=%printer%" + printer);
switches.Add("-f");
switches.Add(tempFile);
processor.StartProcessing(switches.ToArray(), null);
}
}