How to Repeat headers of data grid after page break in document template

0
Hi.    The Headers of a data grid in a document template are only shown on the first page. Is there a way to repeat the headers for the next pages it generates?   Please help   Regards Dylan
asked
3 answers
1

Dilan

I thought about this a bit and came up with a way to do it in a single microflow with no custom Java or other coding necessary.

I have shared my microflow here, and I will walk through what it does below.

To start, here is the domain model that supports this microflow:

The microflow retrieves Materials that start with the letter s or S from a database entity.

First:  get all of the materials, count them and determine number of pages

Next, set up some variables to control looping and page contents

Go through a loop and retrieve 1 page worth of records, create a PDF and add it to the list of pages

When the loop is done, use the Java action MergeMultiplePdfs from community commons to merge our list of pages into a single document, finally, delete all of the single page documents because we don't need them anymore.

The document template I use is pretty simple, just for demonstration purposes:

The resulting combined file can be seen here.

The only thing you need to determine is how many records will fit on a single page.  If you wanted to, it would be easy to have a different first page (different template and maybe number of records), than the other pages.

Hope that is helpful,

Mike

 

answered
0

https://forum.mendix.com/link/questions/4816 mentions the same problem and offers a workaround. I don't think there's a proper solution for this problem yet.

answered
0

I've done this for a customer in the following way:

Work to do upfront:

  1. Generate the document in PDF and download it
  2. Extract the header from the downloaded PDF file (using any kind of PDF editor).
  3. Store the header in a new PDF file (this will be your repeatable header)
  4. Create functionality in your model where you can upload this repeatable header

 

Creating the document in your app:

Asuming you have the functionality present where you create your document. (you'll need to create the document twice)

  1. Determine the amount of pages needed (to make sure you need the repeatable header)
    1. I use a JAVA action to determine the amount of pages (based on the file document).
      1. If you have one page no header is needed, clean up the dummy document (which you used to determine the amount of pages)
      2. if you have multiple you need the header (continue with step 2)
  2. Setting the header is 'simple'. 
    1. You need a JAVA action that can overlay your created pages (starting from page 2).
    2. Retrieve the header from your App
    3. Call the created overlay function and within that action you can overlay the header with your 2nd (and other) pages.

 

You may need to work by trial and error regarding the correct position of your repeatable header. If you need more help, contact me by mail.

answered