C# – Sending PDF to Thermal Printer (Zebra) using c#

cthermal-printer

I am trying to send a PDF to a thermal printer using c#. I have looked at the RawPrinterHelper class here http://support.microsoft.com/kb/322091 but the SendFileToPrinter is not printing the file.

There is no error and the file appears to be printing from the print queue but nothing happens.

The printer works fine as I have been able to print other items on it.

Does anyone know how I can send a PDF to print or how I can possibly use the SendFileToPrinter to work for me.

I am working on Windows 7.

Here is a sample of the code I am using to call the SendFileToPrinter method.

try
        {
            RawPrinterHelper.SendFileToPrinter(PrinterName,@"C:\test.pdf");

        }
        catch (Exception ex)
        {
            Console.WriteLine(" EXCEPTION: {0}", ex.Message);
        }

Update:
Ok, maybe I spoke too soon. I am able to print the PDF to the thermal printer but the issue now is that this is taking a couple of seconds to print and I am looking for something that is "quick". The reason it is slow is that Adobe needs to open up first.

Anyone have any ideas on how to get around this?

Best Answer

Ok, actaully got it sorted.

I was able to do the following and it works perfectly.

string tempFile = @"C:\test.pdf";
            try
            {
                ProcessStartInfo gsProcessInfo;
                Process gsProcess;
                string printerName = PrinterName; 

                gsProcessInfo = new ProcessStartInfo();
                gsProcessInfo.Verb = "PrintTo";
                gsProcessInfo.WindowStyle = ProcessWindowStyle.Hidden;
                gsProcessInfo.FileName = tempFile;
                gsProcessInfo.Arguments = "\"" + printerName + "\"";
                gsProcess = Process.Start(gsProcessInfo);
                if (gsProcess.HasExited == false)
                {

                    gsProcess.Kill();
                }
                gsProcess.EnableRaisingEvents = true;

                gsProcess.Close();
            }
            catch (Exception)
            {
            }

@DavidCrowell, thats for the assistance.

Noel.

Related Topic