Deleting pages in the FinalPass


I am trying to pad out a report with a 'Notes' page so as the total number of pages in the report is always a multiple of 4. This is so as the printing company can bind the document easily.

I have tried creating pages at runtime and inserting them into the frxReport.Objects during the OnManualBuild event. This typically results in a "List Index Out of bounds" when the rest of the FR code runs. I saw this post about swapping pages and that works. I have not found any other posts on dynamically creating pages at runtime though. Is it possible?

What I would like to do is insert pages on the final pass based on whether the number of pages is a multiple of 4: Something like:

LTotalPagesToInsert:=frxReport.Engine.TotalPages mod 4;

if LTotalPagesToInsert>0 then


I've tried adding 3 'Notes' pages to the report designer and then trying to make them visible\invisible according to the number of pages needed to pad the report out. However as the report has a Table of Contents (TOC), its not until the final pass that I know the true number of pages. From what I can see, you can only set a page's visible\invisible property during the first pass.

Has anyone encountedered this issue before and if so, how did you approach it?

Delphi 10.2.3 with FR 2021.0.3.




  • gpigpi Volnovakha, Ukraine

    Add Page2 to report and use in the script

    procedure Page1OnAfterPrint(Sender: TfrxComponent);


    Page2.PageCount := 4 - <Page> mod 4;


Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.