RPE Master Pages are the means through which template designers control the layout of the document for the Word and PDF output. There is one aspect with design of the master pages that makes them harder to use, their properties are static.
This limitation can be overcome by using multiple master pages and toggling the use of one or the other though a variable, essentially allowing a dynamic master page usage in the template. The fundamental problem with this approach is that it requires duplication of the master pages.
RPE 1.2.1 removes this limitation and allows master pages to be fully dynamic. The outline of the typical process to use dynamic master pages is provided below.
A typical scenario where this capability is needed is to change the orientation of the page based on the value of an attribute from the data source, without changing any other property of the master page.
Prior to 1.2.1 the solution was to create master pages with “landscape” and “portrait” orientations but that would otherwise be identical.
With RPE 1.2.1 the solution is described below. The example template, data and the Word output are available here.
- create the master page as needed
- create an internal variable that controls the page orientation, for example pageOrientation_
- use this variable in the master page definition for the orientation property ( this was not previously possible)
- use this master page on the element where you want the switch to occur ( also see point 8 below)
- Calculate the orientation as needed. In my example I switch the master page to Landscape every time I encounter an object with Priority mandatory and change back to Portrait when any other object is found.
With the above steps the switch will only occur for the first time due to how RPE implements the master page switch: RPE switches the master page only if its name is different from the current page OR the force page change value is set to true.
Considering the above and since now a single master page is used you need to explicitly tell RPE when to change the page. This is done in a similar manner to how the orientation is calculated:
- create an internal variable that controls the page change, name it forcePageChange_
- calculate the value of this variable in the same place where you calculate the orientation, in item 3 above. Set it to true when the orientation has to change from Portrait to landscape and viceversa
- Use this variable as the value for the “force page change” property on the element where you have used the master page, item 4 above