3

Presently I'm using the following lines of c# code to automatically print a pdf file to a mobile printer:

        string defFile = (Path.Combine(System.Windows.Forms.Application.StartupPath, tkt_no + "_DEF.pdf"));
        string rwPrinter = "";
        if (GlobalVars.useDefaultPrinter == false) 
        { 
            foreach (string strPrinter in System.Drawing.Printing.PrinterSettings.InstalledPrinters)
            {
                if (strPrinter.StartsWith("ZDesigner"))
                {
                    rwPrinter = strPrinter;
                    break;
                }
            }
        }
        if (jobdo.Equals("print"))
        {
            Process process = new Process();
            process.StartInfo.FileName = defFile;
            if (rwPrinter.Length > 0)
            {
                process.StartInfo.Verb = "printto";
                process.StartInfo.Arguments = "\"" + rwPrinter + "\"";
            }
            else
            {
                process.StartInfo.Verb = "print";
            }
            process.Start();
            process.WaitForInputIdle();
            Thread.Sleep(10000);
            process.Kill();

These above lines are good if the application is on a workstation desktop, but the problem I am having is when it actually prints the pdf file from a Citrix App shortcut, it spawns Adobe Reader (the default for pdf) and doesn't close when print job is done.

So my question is, is there any way to print a pdf document without opening Adobe or similar? Perhaps in the iTextSharp library which I'm using in the same application to populate fields?

Kara
  • 6,115
  • 16
  • 50
  • 57
jfalberg
  • 141
  • 4
  • 16
  • Hell, try this link http://social.msdn.microsoft.com/Forums/vstudio/en-US/56bfe546-680a-45bb-b904-3c9570a6e6a7/how-to-print-pdf-without-opening-adobe-c you can find your answer there. – Marek Jul 16 '13 at 21:32
  • See this link, too: http://stackoverflow.com/a/8360670/231316. Also, Adobe Reader is a _PDF renderer_ while iText is a _PDF generator_. A renderer can take a PDF structure and visually display it. A generator is only able to create/manipulate the raw PDF structure. So iText won't be able to help you print. But you could try FoxIt which doesn't support silent printing last I saw. – Chris Haas Jul 18 '13 at 13:48

0 Answers0