[flexcoders] Priting to Zebra Label printer?

2008-06-27 Thread edward.syrett
Is there any proper, crossplatform way of printing to LPT1 directly
from an AIR App?

We need to send ZPL directly to a Zebra Label printer from a local AIR
app. ZPL is a simple text-based language specifically for the Zebra
range of printers.  

We cannot use the method of printing offered by AIR where you add a
display object to the print job because print data is rendered as a
bitmap. The Zebra printers aren't very good with bitmaps, and we would
certainly never be able to use barcodes with this printing method 

One approach would be to mandate that the user has the Zebra connected
directly to their machine on LPT1, but I can't find any api in AIR
that allows me to write text to a port like that.

We have connected the Zebra printer to a little Print Server thing
that has an ethernet port and a parallel port, and I should therefore
be able to use the Socket class to send the ZPL directly to the port.
 But that throws an error, and I've asked about that in a separate
question entitled #2031: Socket Error.

Thanks,

Ed.



However, AIR only allows



[flexcoders] #2031: Socket Error

2008-06-27 Thread edward.syrett
I'm trying to send a simple string to a Printer Server on our network.
The text is a language called ZPL which is going to our little print
server box that has a Zebra Label printer on its parallel port.

Here's my test app:


?xml version=1.0 encoding=utf-8?
mx:WindowedApplication xmlns:mx=http://www.adobe.com/2006/mxml;
layout=absolute

 mx:Script
 ![CDATA[
 import mx.controls.Alert;


 private function onPrintZpl():void
 {
 var sData:String = ^XA^FWR^CI13 +
 ^LHLabelTop,LabelLeft +
 ^FWB^FO512,899^XGPPI_LAN,1,1^FS^FWR +
 ^FO708,045^A0,40,40^FDUnit 7^FS +
 ^FO659,042^A0,40,40^FDKuehne + Nagel Logistics^FS
+
 ^FO611,042^A0,40,40^FDAppletree Road^FS +
 ^FO562,042^A0,40,40^FDChipping Warden^FS +
 ^FO522,042^A0,40,40^FDBanbury^FS +
 ^FO476,042^A0,40,40^FDOxfordshire^FS +
 ^FO430,043^A0,40,40^FDOX17 1LL^FS +
 ^FO381,042^A0,40,40^FDUnited Kingdom^FS +
 ^BY3,3,10 +
 ^FO141,043^B3R,N,100,Y,N^FD9^FS +
 ^XZ

 try
 {
 var socket:Socket = new Socket();

 //socket.addEventListener(IOErrorEvent.IO_ERROR,
onIOError);

 socket.connect(10.44.180.120, 9100);
 socket.writeUTF(sData);
 socket.flush();

 socket.close();
 }
 catch(error:Error)
 {
 Alert.show(error.message);
 }
 }

 private function onIOError(event:IOErrorEvent):void
 {
 }

 ]]
 /mx:Script

 mx:VBox width=100% label=Printing
 mx:Button label=ZPL Print click=onPrintZpl()/
 /mx:VBox

/mx:WindowedApplication

With the app as it stands, I can hit the ZPL Print button, the label
is printed, but then the app throws this error:

[SWF] SocketTest.swf - 902,761 bytes after decompression
Error #2044: Unhandled IOErrorEvent:. text=Error #2031: Socket Error.
 at
SocketTest/onPrintZpl()[C:\Development\Monarch\Test\SocketTest\src\Socke\
tTest.mxml:28]
 at
SocketTest/___SocketTest_Button1_click()[C:\Development\Monarch\Test\Soc\
ketTest\src\SocketTest.mxml:58]

If I uncomment the call to addEventListener() for IOErrorEvent.IO_ERROR,
the app runs without any errors, but the label isn't printed.

Any comments/help gratefully received.

Thanks,

Ed.