delphi - Zebra Printer direct communication -


based on this question have implemented following code send direct commands zebra tlp2844

var   cmm: ansistring;   i: integer; begin   commands.savetofile('path\to\a\file');   printer.begindoc;   cmm := '';   := 0 commands.count-1     cmm := cmm + commands[i] + #10;   escape(printer.canvas.handle, passthrough, length(cmm), pansichar(cmm), nil);   printer.enddoc; end; 

commands tsringlist containing commands want send printer. note save commands text file.

well, if send text file print, via driver preferences, using tools -> action -> send file, prints perfectly.

if use code above, spits rows of labels after printing.

it shows me, obviously, doing wrong here, can't figure out what.

what have tried

  • send commands 1 one , not concatenating them in code. results: nothing gets printed.
  • changing #10 #13#10. results: same crazy behaviour (indeed zebra epl documentatins says ignore #13 finds)

what else should try in order send printer commands exact same way zebra's tool does?

afaik need format buffer expected extescape() api layout. never used escape(), extescape() - , worked zebra printer.

here what msdn doc states:

lpszindata [in] pointer input structure required specified escape. the first word in buffer contains number of bytes of input data. remaining bytes of buffer contain data itself.

so may code such:

  cmm := '00'; // reserve space initial `word`   := 0 commands.count-1     cmm := cmm + commands[i] + #10;   pword(cmm)^ := length(cmm)-2; // store length   if extescape(printer.canvas.handle, passthrough, length(cmm), pointer(cmm), 0, nil)<0     raise exception.create('error @ printing printer');   printer.enddoc; 

be aware if command not formatted (e.g. missing chars), may create out of memory error in printer spooler - yes, i've seen that! in case, may have kill restart printer spooler service... fix code... , try again...

and not forget put esc character @ beginning of each of commands[], requested zebra doc.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -