Recent

Author Topic: Lazarus Printing in Thermal printer, Different printing result  (Read 4549 times)

Kevinn33

  • New Member
  • *
  • Posts: 26
Hello Lazarus Community, I have been googling around and cant find an answer to this problem,
the problem is:
1. When i print a string in a rawmode on a thermal printer using lazarus IDE 1.6.2 (windows 10)
 the result are good, see the photo 1
2. but when i compile and build the same program on Raspberry pi, it turns out the font size are bigger.
see photo 2.
3. i am using these code to do the simple raw printing.
Code: Pascal  [Select][+][-]
  1. unit Printertestingg;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
  9.   Buttons, Printers;
  10.  
  11. type
  12.  
  13.   { TForm1 }
  14.  
  15.   TForm1 = class(TForm)
  16.     Button1: TButton;
  17.     procedure Button1Click(Sender: TObject);
  18.   private
  19.     { private declarations }
  20.     procedure PrintString(S:String);
  21.     procedure PrintSample;
  22.   public
  23.     { public declarations }
  24.   end;
  25.  
  26. var
  27.   Form1: TForm1;
  28.  
  29. implementation
  30.  
  31. {$R *.lfm}
  32.  
  33. { TForm1 }
  34. procedure TForm1.PrintString(S: String);
  35. var
  36.   Written: Integer;
  37. begin
  38.   Printer.Write(S[1], Length(S), Written);
  39. end;
  40.  
  41. const
  42.   MaxBufSize = 256;
  43.  
  44. procedure TForm1.PrintSample; // a kind of procedure
  45. begin
  46.    //Mencetak header dan isi struk
  47.    PrintString('========Selamat Datang========='+LineEnding);
  48.    PrintString('=======Penyewaan  Loker========'+LineEnding);
  49.    PrintString('Tercetak Pada '+DateTimeToStr(Now));//Menampilkan waktu sekarang
  50.    PrintString('Item : 1 Loker    = Rp. 35000,-'+LineEnding);
  51.    PrintString('==============================='+LineEnding);
  52.    PrintString('Total             = Rp. 35000,-'+LineEnding);
  53.    PrintString(LineEnding);
  54.    PrintString('  Simpan Struk pembayaran ini  '+LineEnding);
  55.    PrintString('Struk ini akan digunakan untuk '+LineEnding);
  56.    PrintString('buka loker yang digunakan      '+LineEnding);
  57.    PrintString('Barcode : '+LineEnding+LineEnding+LineEnding);
  58.  
  59. end;
  60.  
  61. procedure TForm1.Button1Click(Sender: TObject);
  62. begin
  63.   Printer.SetPrinter('POS-58');  //Deklarasi nama printer
  64.   Printer.Title := Caption;
  65.   Printer.RawMode := True;
  66.   Printer.BeginDoc;
  67.   PrintSample;
  68.   Printer.EndDoc;
  69. end;
  70.  
  71.  
  72.  
  73. end.
  74.                                                        

Thaddy

  • Hero Member
  • *****
  • Posts: 14197
  • Probably until I exterminate Putin.
Re: Lazarus Printing in Thermal printer, Different printing result
« Reply #1 on: March 19, 2018, 09:36:19 am »
Can you test it against any other linux? I suspect this is an issue about Linux Debian, not a Raspberry Pi issue. Looks like the POS printer supports multiple raw fonts and picks the wrong one.
Specialize a type, not a var.

rvk

  • Hero Member
  • *****
  • Posts: 6110
Re: Lazarus Printing in Thermal printer, Different printing result
« Reply #2 on: March 19, 2018, 10:50:35 am »
Yes, this is defenitly a font-choosing problem.

But what's the mess above the second printout? If it is really printed it could set the printer in a default bigger font mode.

Otherwise... the POS-58 accepts escape codes to switch to another (smaller) font. So you could send it in raw-mode. But make sure you solve the junk above the print first.
http://www.xmjjdz.com/downloads/manual/en/POS-58%20User's%20Manual.pdf

You could also hard-set the default font on the device.
But it's best to just send the correct escape sequence for the font you want.
« Last Edit: March 19, 2018, 10:53:08 am by rvk »

Kevinn33

  • New Member
  • *
  • Posts: 26
Re: Lazarus Printing in Thermal printer, Different printing result
« Reply #3 on: March 19, 2018, 11:48:28 am »
Can you test it against any other linux? I suspect this is an issue about Linux Debian, not a Raspberry Pi issue. Looks like the POS printer supports multiple raw fonts and picks the wrong one.

I'm sorry, but i dont have another linux device to test, I wonder if anyone know how to set rawmode font size...

Yes, this is defenitly a font-choosing problem.

But what's the mess above the second printout? If it is really printed it could set the printer in a default bigger font mode.

Otherwise... the POS-58 accepts escape codes to switch to another (smaller) font. So you could send it in raw-mode. But make sure you solve the junk above the print first.
http://www.xmjjdz.com/downloads/manual/en/POS-58%20User's%20Manual.pdf

You could also hard-set the default font on the device.
But it's best to just send the correct escape sequence for the font you want.

dunno what happend in the second printout, but when i try print from terminal, it turns out the font size is small (the size that i wanted) and no other mess like the second picture

Thaddy

  • Hero Member
  • *****
  • Posts: 14197
  • Probably until I exterminate Putin.
Re: Lazarus Printing in Thermal printer, Different printing result
« Reply #4 on: March 19, 2018, 01:40:50 pm »
Install virtualbox on windows. Feed it a Debian iso.
Specialize a type, not a var.

SymbolicFrank

  • Hero Member
  • *****
  • Posts: 1313
Re: Lazarus Printing in Thermal printer, Different printing result
« Reply #5 on: March 20, 2018, 01:37:10 pm »
How is the printer connected? Most likely, there is a COM-port somewhere you can use to print. Or a virtual-Com-port driver you can install. See if you can find out which one.

Next add the text to a TStringList and use TStringList.SaveToFile('COMn'), where "n" is the number of the COM-port. Like this:

Code: Pascal  [Select][+][-]
  1. procedure Print(COMPort: string);
  2. var
  3.   List: TStringList;
  4. begin
  5.   List := TStringList.Create;
  6.   List.Add('========Selamat Datang========='+LineEnding);
  7.   List.Add('=======Penyewaan  Loker========'+LineEnding);
  8.   List.Add('Tercetak Pada '+DateTimeToStr(Now));//Menampilkan waktu sekarang
  9.   List.Add('Item : 1 Loker    = Rp. 35000,-'+LineEnding);
  10.   List.Add('==============================='+LineEnding);
  11.   List.Add('Total             = Rp. 35000,-'+LineEnding);
  12.   List.Add(LineEnding);
  13.   List.Add('  Simpan Struk pembayaran ini  '+LineEnding);
  14.   List.Add('Struk ini akan digunakan untuk '+LineEnding);
  15.   List.Add('buka loker yang digunakan      '+LineEnding);
  16.   List.Add('Barcode : '+LineEnding+LineEnding+LineEnding);
  17.   List.SaveToFile(COMPort);
  18.   List.Free;
  19. end;

This will circumvent the printer driver, which often emulates a Canvas.

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Lazarus Printing in Thermal printer, Different printing result
« Reply #6 on: March 20, 2018, 03:23:18 pm »
make sure that you use the correct code page on the string send to the printer as well.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

 

TinyPortal © 2005-2018