I am using Apache's XML Graphics FOP 2.6 to create a PDF document containing at least 2 pages. There is no maximum number of pages.
The exact same header is used on every page.
Page 1 (see attached)
Needs to contain text with the total number of boxes, the total number of items included in the total number of boxes and a table with 1, 2 or 3 rows. On each row, there is a photo of the box, its name and the number of items it contains. There will be at least one box containing at least one item.
Page 2
Exists only if there are 4 or more boxes and it contains rows 4, 5, 6, 7, 8 and 9 (6 rows in total) of the table from Page 1. If there are more than 9 (= 3 6 X 1) boxes, there needs to be a new page that will contain the layout from Page 2, but containing the rows for boxes 10, ..., 15. This pattern will be followed until the last box.
Page 3
Will contain the photo, name and number of items of the first box. Underneath there will be a table, with a row containing the column names and at most 4 rows, corresponding to the first 4 items from the first box.
Page 4
If the first box has more than 4 items, there will be new page, called Page 4, containing only the continuation of the table, including the row with the column names. It will have 7 items in total and be followed by another page if the first box has more than 11 (= 4 7 X 1) items. And so on until the end of all items.
Page 5 (not attached to avoid repetition)
Will follow the same logic as Page 3, but in this case for the second box, if there is a second box. And so on until the end of all boxes.
Can anyone, please help me with an idea on how to build the layout-master-set in the XSL file for my requirements? I am not looking for the entire solution. Only for the general layout structure. The answer does not have to be too detailed or too bespoke for my needs. I can adapt it if needed.
<xsl:template match="/doc">
<xsl:variable name="Logo"><xsl:value-of select="Logo"/></xsl:variable>
...
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:fox="http://xmlgraphics.apache.org/fop/extensions"
font-family="Nexus Sans Pro" font-weight="normal">
<fo:layout-master-set>
<fo:simple-page-master master-name="Boxes-A4" page-width="297mm" page-height="210mm"
margin-top="0mm" margin-bottom="0mm" margin-left="0mm" margin-right="0mm">
<fo:region-body region-name="xsl-region-body"/>
<fo:region-before region-name="xsl-region-before" extent="70mm"/>
</fo:simple-page-master>
<fo:simple-page-master master-name="Items-A4" page-width="297mm" page-height="210mm"
margin-top="0mm" margin-bottom="0mm" margin-left="0mm" margin-right="0mm">
<fo:region-body region-name="xsl-region-body"/>
<fo:region-before region-name="xsl-region-before" extent="70mm"/>
</fo:simple-page-master>
</fo:layout-master-set>
I have tried the code above (using xsl:stylesheet version="1.0"), but have failed in getting things to be laid out appropriately. The rows of the table that do not fit on a page do not get displayed on the following page, even though I mark appropriate rows with break-before="page" aka page-break-before="always". As an aid, I can insert the indices from the backend data structure into the parameters used by the library so that I know each element's index.
Thank you very much.
Combining this with @Tony Graham's suggestion on doing the tables and you have the whole layout. If you wonder how that works with automatic page flows, here is the exact example above with a few more boxes and one box (Box 4) with more items ... I only changed the fo:block font-size to cause pagination.