Recent

Author Topic: FPReport QRCode  (Read 179 times)

dseligo

  • Hero Member
  • *****
  • Posts: 1372
FPReport QRCode
« on: September 15, 2024, 11:33:44 pm »
I am exporting generated FPReport to PDF, but I have problems with QRcode - sometimes there are some glitches around and in the QRCode. Example is attached PDF (generated from attached program) and image (from more complex report).

These glitches somehow depends on other report elements. I also noticed that when I turn on 'Use Heaptrc unit (check for mem-leaks)', glitches disappear.
In my program they don't appear on first run of the report, but on 2nd and subsequent runs of report.

Am I using TFPReportQRCode in the wrong way or is there some bug in this class?

This is happening under Lazarus 3.4 under Windows 11, but also with Lazarus 2.2.4 on Android (LAMW).

Here is the test program (I attached Lazarus project):
Code: Pascal  [Select][+][-]
  1. program project1;
  2.  
  3. uses
  4.   SysUtils, LCLIntf, fpreport, fpreportqrcode, fpreportpdfexport;
  5.  
  6. var report: TFPReport;
  7.     page: TFPReportPage;
  8.     header: TFPReportPageHeaderBand;
  9.     title: TFPReportTitleBand;
  10.     exporter: TFPReportExporter;
  11.     qrCode, qrCode2: TFPReportQRCode;
  12.  
  13. begin
  14.   if PaperManager.PaperCount = 0 then
  15.     PaperManager.RegisterStandardSizes;
  16.  
  17.   report := TFPReport.Create(nil);
  18.   try
  19.     page := TFPReportPage.Create(report);
  20.     page.Orientation := poPortrait;
  21.     page.PageSize.PaperName := 'A4';
  22.     page.Margins.Left := 20;
  23.     page.Margins.Top := 20;
  24.     page.Margins.Right := 20;
  25.     page.Margins.Bottom := 20;
  26.     page.Font.Name := 'LiberationSans';
  27.  
  28.     header := TFPReportPageHeaderBand.Create(page);
  29.     header.Layout.Height := 50;
  30.  
  31.     qrCode := TFPReportQRCode.Create(header);
  32.     qrCode.Layout.Top := 0;
  33.     qrCode.Layout.Left := 15;
  34.     qrCode.Layout.Width := 38;
  35.     qrCode.Layout.Height := 38;
  36.     qrCode.Value := 'abcde12345abcde12345abcde12345abcde12345abcde12345';
  37.     qrCode.Center := True;
  38.  
  39.     title := TFPReportTitleBand.Create(page);
  40.     title.Layout.Height := 50;
  41.  
  42.     qrCode2 := TFPReportQRCode.Create(header);
  43.     qrCode2.Layout.Top := 0;
  44.     qrCode2.Layout.Left := 60;
  45.     qrCode2.Layout.Width := 38;
  46.     qrCode2.Layout.Height := 38;
  47.     qrCode2.Value := 'abcde12345abcde12345abcde12345abcde12345abcde12345';
  48.     qrCode2.Center := True;
  49.  
  50.     report.RunReport;
  51.     exporter := TFPReportExportPDF.Create(nil);
  52.     exporter.SetFileName('test.pdf');
  53.     report.RenderReport(exporter);
  54.   finally
  55.     exporter.Free;
  56.     report.Free;
  57.   end;
  58.  
  59.   OpenDocument('test.pdf');
  60. end.

 

TinyPortal © 2005-2018