Working with Logical and Physical Pages

Genero Report Writer video scripts

Related video: Working with Logical and Physical Pages



Intro splash

Do you need to have multiple report pages appear on a physical page? In this presentation, I will cover working with logical and physical pages, within the application code and within the report design.

Slide showing logical / physical graphic

Typically, we do not think in terms of logical and physical pages when we create a report, as we expect each report page to print on its own physical page. There can be times, however, when you need to have multiple report pages print on a single physical page.

In terms of definitions, a logical page refers to the page defined by the paper settings of the report design document, or by API calls within the report application itself.

To implementing logical page mapping — the mapping of logical to physical pages — the report application calls reporting API functions that specify how the logical pages will be mapped to the physical pages.

Studio demo: Simple List Report

For my demonstrations, I am going to use a report that I have created and named the “simple list report”.  I’ve set up my Reports demo application to include this report, which outputs the default of one logical page per physical page.

Slide: Reporting API functions

In order to implement logical page mapping — in order to have multiple logical pages on each physical page — I need to add some page-related Reporting API functions to the report application. These include the fgl_report_selectLogicalPageMapping, fgl_report_configureMultipageOutput, and fgl_report_setPaperMargins.

Help demo: Showing functions from documentation: function list

Information about these functions can be found in the Genero Report Writer documentation, specifically within Reporting API functions relating to the page.

Help demo: Showing functions from documentation: fgl_report_ selectLogicalPageMapping

The first function that we will add is fgl_report_selectLogicalPageMapping. This function takes a single STRING parameter. To specify that multiple ISO or JIS sized pages be printed on the physical page, you set this parameter to “multipage”.

Help demo: Showing functions from documentation: fgl_report_ configureMultipageOutput

The next function to add is fgl_report_configureMultipageOutput. There are three parameters to specify for this function.

The first parameter is pageExponent. With this parameter, you specify the exponent to apply to the number 2.  If you enter 2, for example, you are specifying 2 to the power of 2, resulting in 4 logical pages printed on a physical page. If you enter 3, you are specifying 2 to the power of 3, resulting in 8 logical pages printed on a physical page. Enter 4, and you end up with 16 pages, and so on.

The second parameter is the isoNumber parameter, which takes an integer. As per our example, if you want the logical page to be an ISOA4 page, you would enter 4.  If the page is defined as an ISO or JIS sized page — defined in the report definition or set by in the application with fgl_report_configurePageSize — then you can enter NULL for this parameter and the pre-defined size is used.

The last parameter specifies whether you want the layout to be portrait or landscape. For portrait, set to TRUE; for landscape, set to FALSE.

Help demo: Showing functions from documetnation: fgl_report_ setPaperMargins

The last function that I will add is fgl_report_setPaperMargins, which allows me to specify a top, bottom, left, and right margin size for my physical report page. This function is optional, but it does allow you to tweak the margins for the resulting physical report page.

Studio demo: Modify OrderReport.4gl

Demo: Report Viewer

Let’s switch back to Studio and add this code to our report application.

We need to add these Reporting API functions to the function that configures our report, so I am looking for my configureReport function.

We need to add it prior to calling fgl_report_commitCurrentSettings.

To save time, I’ve already added the code here; let me remove the comments and review the code. We check to see if the report is the Sample List Report. If it is:

  1. we use fgl_report_selectLogicalPageMapping to specify a multipage report;
  2. we use fgl_report_configureMultipageOutput to specify 4 logical pages per physical page (two to the power of two), an ISO page size of 4, and a portrait layout; and
  3. we use fgl_report_setPaperMargins to provide a top and bottom margin of 2.5 centimeters and a left and right margin of .5 centimeters.

We save our changes, and run the report.

Switching to Report Viewer, we can see that we now have four logical pages for each physical page.

Our report displays the “logical page number” on each logical page. Now let’s add the physical page numbers to that same footer.

Slide: Review numeric functions

To add the physical page numbers to a report footer, we must do the following:

  1. Add a Page Number Box to the report footer
  2. Edit the Text Expression property to include the numeric methods that return physical page information: the getPhysicalPageNumber returns the physical page, and the getTotalNumberOfPhysicalPages returns the total physical page count. These two methods do not take arguments.

Demo: Report Designer

To show this, let us look at the Sample List Report design document.

I find the footer, and I add a new Page Number Box.

Then, having selected the new Page Number Box, I search its properties for the Text Expression property, and I open the expression editor.

I start by entering a string within quotes that states Physical Page “ then a plus sign, then I start entering my first method, starting with format. The CTRL + SPACE BAR combination opens up the code completion box, allowing me to select from a list of valid choices based on the current context.

I specify the getPhysicalPageNumber method, followed by a set of parentheses, then a comma, and I want the number displayed as an ARABIC number.

Next I add an additional string, including the word OF surrounded by spaces

And finally I add another format method, passing in the getTotalNumberOfPhysicalPages method and specifying that the resulting number display as an ARABIC number.

I ensure that I have Expression OK , and I save my changes.

The report is ready to run.

Demo: Studio

I run the report. Since I changed only the report definition, I do not need to recompile the application.

Demo: GRV

Looking at the report created, I can see that it now contains information in the footers about the physical page.