fikri zainul wrote 11 lines
Hi all,
I have a printer (Epson TM U220D, plugged in COM1 port) and my OS
Linux/Fedora10 I can't found the driver printer for this OS (only for SUSE
and Ubuntu that Epson provided). (Using Generic/TextOnly driver, not
working)
So, I can't do printing process for my lazarus application.
My first question is,
[?] Do you know how to handle this situation? (Driver problem)
Yes, set it in cups properly, but DO NOT use Generic Text, use Raw printing driver and set proper ESC/POS.
This is how I do that:
1.Prepare TStringList with commands and data to be printed. eg:
MyPosList := TStringList.Create;
MyPosList.Add(SEQUENCE_FOR_PRINTER_INITIALIZATION(read escposmanuals))
MyPosList.Add('Hello world line 1');
MyPosList.Add('Hello world line 2');
MyPosList.Add('Hello world line 3');
MyPosList.Add(SEQUENCE_FOR_CUTTER (if there's cutter));
MyPosList.SaveToFile(YourTempFileOrWhatever);
MyFunctionForPosPrinting(YourTempFileOrWhatever) (look below)
2.Save it to temp file eg. /tmp/myposprinter_XXXXX.txt 3.call cups to print it to desired pos printer (via Libc.System()/TProcess/ExecuteProcess) -> lpr -PMYPOSPRINTER /tmp/myposprinter_XXXXX.txt
I'm using ExecuteProcess()
http://www.freepascal.org/docs-html/rtl/sysutils/executeprocess.html
4.Delete temp file.
Show quoted text 6 lines
Temporary, I try to print via command line (Terminal/Dos command like) to
the printer using command line 'cat textfile.log > /dev/ttyS0',
and it's worked. Something printed.
DO NOT USE IT EVER. It's direct port printing and you can have troubles on user machines with permissions, selinux etc etc.
Cups handles that fine.
Show quoted text 7 lines
And the (second) question is,
[?] How to apply this command (multiple lines sometimes) in Lazarus Code?
(By pressing from a button maybe) Can you all give me some codes to
execute?
1.Use ESC/POS docs (or any other docs for your pos printer, but I guess that TMU220D is pure ESC/POS printer.
2.Do as I explained above.
zeljko
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120210/134c00f7/attachment-0001.html>