Hi Emanuele !
Sorry for the late answer. The sample that I posted was for a Datamax printer. So in Eltron/Zebra,
it should go something like this:
char sn = '"';
MemoryStream memStrm = new MemoryStream();
StreamWriter sw = new StreamWriter(me mStrm);
sw.WriteLine("\ n"); // new line to start command structure
sw.WriteLine("N "); // clear image memory from last printed label
sw.WriteLine("X 0,0,4,752,584") ; // draw a box
sw.WriteLine("L O0,144,752,4"); // draw a line
sw.WriteLine("A 40,400,1,1,1,1, N," + sn + "Made in Norway" + sn);
sw.WriteLine("B 280,440,0,1,2,3 ,96,B," + sn + "S 000001" + sn); // write a barcode
sw.Flush();
sw.WriteLine("P 1"); // print 1 label
sw.WriteLine("" ); // empty line
sw.Flush();
memStrm.Positio n = 0;
LabelPrint.Send DocToPrinter(pd .PrinterSetting s.PrinterName,m emStrm);
sw.Close();
The sample above is simple, but it's all I had time to do now. Not that you should add a method to
the article file called SendDocToPrinte r. I've posted the code below:
<code for the SendDocToPrinte r function>
public static bool SendDocToPrinte r( string szPrinterName, MemoryStream ms)
{
// Open the file.
//FileStream fs = new FileStream(szFi leName, FileMode.Open);
// Create a BinaryReader on the file.
BinaryReader br = new BinaryReader(ms );
// Dim an array of bytes big enough to hold the file's contents.
Byte []bytes = new Byte[ms.Length];
bool bSuccess = false;
// Your unmanaged pointer.
IntPtr pUnmanagedBytes = new IntPtr(0);
int nLength;
nLength = Convert.ToInt32 (ms.Length);
// Read the contents of the file into the array.
bytes = br.ReadBytes( nLength );
// Allocate some unmanaged memory for those bytes.
pUnmanagedBytes = Marshal.AllocCo TaskMem(nLength );
// Copy the managed byte array into the unmanaged array.
Marshal.Copy(by tes, 0, pUnmanagedBytes , nLength);
// Send the unmanaged bytes to the printer.
bSuccess = SendBytesToPrin ter(szPrinterNa me, pUnmanagedBytes , nLength);
// Free the unmanaged memory that you allocated earlier.
Marshal.FreeCoT askMem(pUnmanag edBytes);
return bSuccess;
}
</code for the SendDocToPrinte r function>
I'm trying to print on an Eltron TLP2247. Using the example that you
suggest, nothing appen on the printer.
How can i sent EPL command do the printer?
Thnks
EMA
Best wishes
Kai Bohli
ka***********@o nline.no
Norway