Author Topic: [Solved] Possible Bug in Printers Unit?  (Read 294 times)


  • New Member
  • *
  • Posts: 12
[Solved] Possible Bug in Printers Unit?
« on: November 04, 2020, 02:37:49 pm »
I've been working on generating some reports from Free Pascal/Lazarus.   I believe I have found a minor bug in the printers unit having to do with PageNumber.

The issue I was having was that the Page number of every report began with three.   I decided to look into the code to see why.

What I was doing:

Code: Pascal  [Select][+][-]
  1. BeginDoc;
  2. BeginPage;
  3. // Print some stuff
  4. NewPage;
  5. // Print some more stuff
  6. EndPage;
  7. EndDoc;

Looking at the printers unit code, it appears my call to BeginPage is not necessary, as BeginDoc calls it before it returns.  Removing that call, changed the results, but now I was still getting a beginning page number of two.   

Looking Closer, BeginDoc sets the PageNumber to 1 near the beginning, then before it exits it calls BeginPage, which increments that PageNumber, resulting in all reports starting at page two.

I believe the solution is to change BeginDoc to initialize the PageNumber to zero instead of one.

I resorted to doing my own page counter as only adds about two lines of code, but since the class is supposed to do it for me, I thought I would ask about this.

EDIT:  Turns out I was right... it's a bug.   See 0037682
« Last Edit: November 29, 2020, 07:09:42 pm by PJW »


  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3933
  • I like bugs.
Re: Possible Bug in Printers Unit?
« Reply #1 on: November 04, 2020, 08:09:53 pm »
EDIT:  Turns out I was right... it's a bug.   See 0037682
It should be fixed. Did you test with revision 64104 or later?
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.


TinyPortal © 2005-2018