Four Js Development Tools Forum

General => Ask Reuben => Topic started by: Reuben B. on October 06, 2021, 06:28:36 am



Title: Ask Reuben 98 - Page N of M
Post by: Reuben B. on October 06, 2021, 06:28:36 am
One of the key elements in the architecture of Genero Report Writer is the streaming concept.  If the report format allows, this is the ability to view or physically print page 1 of a report as soon as the report engine has finished page 1 and has moved onto rendering page 2.  This means that in the event of a large report, the engine does not have to keep many pages in memory, and the end user does not have to wait for the report to be finished in entirety before they starting printing or viewing the report.  The printer will start printing page 1 whilst the engine figures out what is in page 2 etc.
 
This design has some implications for when you want to print a page count, typically in the form of a "Page N of M".  If you look at a typical invoice your household receives, say a credit card statement, if there are 3 pages it may say "Page 1 of 3", "Page 2 of 3", "Page 3 of 3 etc.  With the architecture of Genero Report Writer, this requires the streaming concept to pause until the engine knows what the number it needs to print on the page is.  It will leave some space on the page and come back and fill in the space when it knows the total number of pages in the report or group, and then output those pages.  In the worst case scenario where you are printing the total number of physical pages on every page, this may mean that the whole document maybe held in memory until the whole report is determined and the engine can go back to every page and insert the total page number onto each page.
 
Due to this special processing that is required with a page number, it gets its own drawable "Page Number", that you can find in the Drawables section of the Toolbox.  To learn more about this and how to print a Page N of M string, read more at https://4js.com/ask-reuben/ig-98/