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:
BeginDoc;
BeginPage;
// Print some stuff
NewPage;
// Print some more stuff
EndPage;
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