Show quoted text 11 lines
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
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
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
---------------------------------------------------- Thank you very much to Zeljko for your answers
----------------------------------------------------
Here what I do exactly:
PRINTER PART
1. Plug my serial TM-U220D printer to my Linux Fedora 10 computer
2. Add Printer using CUPS (Common Unix Printing System) by typing http://127.0.0.1:631 on address bar mozilla
3. Setting Device to Serial Port #1
4. Setting Baud rate to 9600 ( my friend recommended )
5. Setting Make/Manufacture by RAW (thanks to Zeljko, I'm using Generic text before but won't work)
6. Setting Model to Raw Queue
LAZARUS PART
1. Add Printer4Lazarus package
2. Add printers in Uses (Uses Printers)
3. Create method
procedure PrintRawString(const S:String);
var
? Written: Integer;
begin
??? Printer.Write(S[1], Length(S), Written);
end;2. Use the method
procedure TForm1.PrintItClick(Sender: TObject);
begin
? Printer.Title := ?My Title?;
? Printer.RawMode := True;
? Printer.BeginDoc;
? PrintRawString(?Print This String?);
? Printer.EndDoc;
end;3. We can add some ESC/p codes to string.
PrintRawString(Chr(27)+Chr(97)+Chr(1)+?Print This String?);? //center alignment
------------------------------------------------------------------------------------------------
That's All :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120220/58ee1427/attachment.html>
