Recent

Author Topic: Barcode.pas printing in raspberry pi stretch  (Read 1192 times)

Kevinn33

  • New Member
  • *
  • Posts: 26
Barcode.pas printing in raspberry pi stretch
« on: April 19, 2018, 03:13:09 pm »
Hi, recently i am doing a project and it consist of a system that have to be able print a barcode in thermal printer
i use this code in lazarus windows 10 and it works great.
but then when i copy the project and do clean build, compile and run,
the program run but it wont print anybarcode that i want

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, StBarC;
  10.  
  11. type
  12.  
  13.   { TForm1 }
  14.  
  15.   TForm1 = class(TForm)
  16.     Button1: TButton;
  17.     StBarCode1: TStBarCode;
  18.     procedure Button1Click(Sender: TObject);
  19.   private
  20.     { private declarations }
  21.     procedure PrintString(S:String);
  22.     procedure PrintSample;
  23.   public
  24.     { public declarations }
  25.   end;
  26.  
  27. var
  28.   Form1: TForm1;
  29.  
  30. implementation
  31.  
  32. {$R *.lfm}
  33.  
  34. { TForm1 }
  35. procedure TForm1.PrintString(S: String);
  36. var
  37.   Written: Integer;
  38. begin
  39.   Printer.Write(S[1], Length(S), Written);
  40. end;
  41.  
  42. const
  43.   MaxBufSize = 256;
  44.  
  45. procedure TForm1.PrintSample; // a kind of procedure
  46. begin
  47.    //Mencetak header dan isi struk
  48.    PrintString('========Selamat Datang========='+LineEnding);
  49.    PrintString('=======Penyewaan  Loker========'+LineEnding);
  50.    PrintString('Tercetak Pada '+DateTimeToStr(Now));//Menampilkan waktu sekarang
  51.    PrintString('Item : 1 Loker    = Rp. 35000,-'+LineEnding);
  52.    PrintString('==============================='+LineEnding);
  53.    PrintString('Total             = Rp. 35000,-'+LineEnding);
  54.    PrintString(LineEnding);
  55.    PrintString('  Simpan Struk pembayaran ini  '+LineEnding);
  56.    PrintString('Struk ini akan digunakan untuk '+LineEnding);
  57.    PrintString('buka loker yang digunakan      '+LineEnding);
  58.    PrintString('Barcode : '+LineEnding);
  59.  
  60. end;
  61.  
  62. procedure TForm1.Button1Click(Sender: TObject);
  63. begin
  64.   Printer.SetPrinter('POS-58');  //Deklarasi nama printer
  65.   Printer.Title := Caption;
  66.  // Printer.RawMode := True;
  67.  // Printer.BeginDoc;
  68.  // PrintSample;
  69.  // Printer.EndDoc;
  70.   Printer.RawMode := False;
  71.   Printer.BeginDoc;
  72.   StBarCode1.Code:=IntToStr(Random(999999)); //menghasilkan nilai random untuk barcode
  73.   StBarCode1.PaintToCanvas(Printer.Canvas,Rect(100,-200,100,200)); //print barcode dalam bentuk canvas
  74.   Printer.EndDoc;
  75. end;
  76.  
  77.  
  78. end.
  79.  
so i wonder if anyone can help with this? :(

 

TinyPortal © 2005-2018