开发者

Print to a UPS / Fedex Thermal printer?

I have a client asking if their web application (PHP) can easily print to a UPS / Fedex thermal lab开发者_StackOverflow中文版el printer.

So for instance, I can get back a PDF from UPS/Fedex with the shipping label. I just need to print that.

Does anyone know if you can print directly to these printers or, if not, if there's another way to do it?

EDIT: To clarify, all I want to accomplish is to be able to print to these printers, without having to make my client ALT-TAB to some third-party application like UPS Worldship or ShipRush or QuickBooks Shipping Manager and clicking 'Print' within that application. Do-able?


Getting the labels in correct format

The FedEx & UPS APIs provide options to get thermal label specific types. You will beat your head on the keyboard trying to get PDFs to print properly on thermal printers.

Some common thermal types EPL/EPL2, ZPL/ZPLII. Most thermal printers will accept documents matching one of these types.

For Fedex something like this in your ShipRequest - This is using the FedEx WSDL for shipping.

RequestedShipment.LabelSpecification.ImageType = FedExShipService.LabelSpecificationImageType.ZPLII

And UPS - Building XML to post to the UPS service.

<LabelSpecification>
 <LabelPrintMethod>
  EPL2
 </LabelPrintMethod>
</LabelSpecification>

Printing the labels

You will need to essentially send "raw" data to the printer. I started with this article and adopted it to my solution. FedEx for example returns a byte array which contains the label information - I convert this to a string and then send to the printer.

'Convert from Byte Array to String
Dim enc As System.Text.ASCIIEncoding = New System.Text.ASCIIEncoding()
Dim strConverter As String = enc.GetString(<ByteArrayFromFedEx>)

http://www.paulaspinall.com/post/2008/05/31/Sending-data-direct-to-a-printer.aspx

There is also another thread on SO about this topic.

Sending raw data to FedEx Label printer


I used to work on UPS shipping systems and yes you can print using the thermal printers. You need the correct drivers installed to do this. Depending how you want to print will also determine how you need to install the printer (local or shared printer). HTH


Your best source of information on how to print will come from the printer manufacturors web sites. I have referred to this article in the past when developing solutions for customers that consume the UPS API's. Sending Raw EPL2 Directly to a Zebra LP2844 via C#".

This blog post goes into good detail about printing labels from code. Dn't be scared off because it has C# in it's title.

The manufacturers do an okay job of providing the information you need.


Shiprush has an api you can use to generate labels from code. It is pretty flexible, and can either send the label to a printer or return the label to your code for you to handle.


This open source applet would allow you to print from PHP. I personally stay away from Java but it may do the trick.

http://code.google.com/p/jzebra/


You will not be able to print the carrier PDF to the device, however you can take the raw EPL/ZPL code from the carrier and have that sent to the printer.

There is an ActiveX control from UPS that you can install. If you return the EPL stream with a MIME type of application/epl2 the ActiveX control will take the data and send it to the thermal printer.

Google "ups thermal activex"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜