0

I have a function created in C# (WinForms) which saves the file as gif image in local directory. How can I access it and send it to printing to one of my network printers?

I have this code here right now:

internal void PrintLabels(string printerInfo, List<string> shippingLabels)
{
    //this is where I print to printer...
    foreach (string labelPath in shippingLabels)
    {

    }

}

Any help?

VMAtm
  • 27,943
  • 17
  • 79
  • 125
RG-3
  • 6,088
  • 19
  • 69
  • 125

3 Answers3

1

An alternative method would be to programmatically create pdf document/s that you then batch print via CommandLine

Take a look at the iText library.

Once you have created your files, you can print them via a command line (you can using the Command class found in the System.Diagnostics namespace for that)

If you're doing all this from a batch, then you'll want to also be notified (perhaps programmatically) if something goes wrong with the print queue that you are printing to. I believe there is a class for that.

For more information on the subject, try here.

Todd Richardson
  • 1,119
  • 1
  • 11
  • 22
0

I have bunch of 'gif' images. Your all links are for the .txt files. This is my code:

 public void PrintShippingLabels()
    {

        //mock of what the reset of the program will produce up to this step
        List<string> shippingLabels = new List<string>();
        for (var i = 0; i < 10; i++)
        {
            var trackingNumber = "1ZR02XXXXXXXXXXXXX" + i + ".gif";
            shippingLabels.Add(trackingNumber);
            CreateSampleShippingLabel(trackingNumber);
        }

        Assert.AreEqual(10, shippingLabels.Count);

        IceTechUPSClient.Instance.PrintLabels("", shippingLabels);

    }

  public void PrintLabels(List<string> shippingLabels)
    {
        //this is where I print to printer...
        PrintDocument pd = new PrintDocument();
        foreach (string labelPath in shippingLabels)
        {  
            pd.Print();

        }

    }
RG-3
  • 6,088
  • 19
  • 69
  • 125
0

Check the printer you have. Some devices now have the ability to print gif, jpeg, tiff, etc. natively without requiring the conversion into PCL or PostScript datastreams (or other print language). If this is the case you could just send the file via the LPR protocol, directly over port 9100 or directly through a Windows print queue (http://support.microsoft.com/kb/322091)

Douglas Anderson
  • 4,652
  • 10
  • 40
  • 49