[#4324] - DOCX: page header/footer band in page header and footer to allow generation of editable letters

Feature request
Project: Severity:
Component: Reproducibility:
Assigned to:

The new DOCX exporter provides tables with the text as payload instead of frames. This allows to a certain level the generation of letters. These letters can be changed somewhat by office workers. Simple text changes (correct typos) possible.

One problem occurs:
Page header and footer band occur in page flow and move for instance the page number to another page if text is changed too much.

Contents of page header and page footer band should be placed in DOCX as header/footer with correct height.

teodord's picture
Joined: Jun 30 2006 - 9:00am
Last seen: 1 day 9 hours ago




I don't think I fully understand how the document will behave in case the page headers and footers are true DOCX header and footer sections.

If the page footer contains page level totals, in case the letter is edited and page breaks change, do you expect these totals that JR already calculated to be automatically updated when the page content changes?

What about the page number in the footer and the total page number? If the letter ends up having more pages after being edited, what page footer should the additional pages have? A page footer that contains Word fields/formulas for page numbers, so that they display correct values for the additional pages?

What if the page header is not the same for all pages? Which instance of the page header should be used as header for the whole DOCX file?
The header on the first page? The one on the second page? Which one?

Thank you,



Anything new on this one?

Thank you,



why is the content of the page footers, when exporting to docx format, sometimes to the next (wrong) side pushed?

See also question in the forum:




Please try answer to the questions I've asked above with regards to how this feature should actually work.

Thank you,


Hello teodord and thank you for your quick answer.

I think JR should add the header and footer the same way MS Word 2007/2010 is adding it.
For example, in my report I need to add a header which is the same for all the pages, and a footer containing "page_no out of total_no_pages", document file name, and last date/time the document was saved.

Using MS Word 2010, the footer would contain fields with the data I need, and when inserting a new page the behaviour is this:
* the header appears on the new page and is the same
* the page_no/total_no_pages updates automatically,
* date/time the document was saved updates automatically, but after saving the document
* document file name doesn't update automatically, especially when clicking File->SaveAs and saving with a different name. So I have to manually right click on the field and select Update Field.

This kind of behaviour would be desired to exist in JR.
Thank you,


Hi Teodor,

Is there any update on this issue? The features as requested by Cristian are good enough.

Thanks & Regards

Jubi John


we want, at least , the header page and footer
page to be always the same,
only the page number and the number total pages will change when adding a new page.

thank you

Kane Y. Mamadou


I believe just adding the possibility to convert Jasper headers and footers into true docx headers and footers would be sufficient (and go a long way) as a first step. Docx is able to have different headers and footers for the first and consecutive pages, so Jasper's first page header / first page footer capability should be doable.

I'm not deeply into the docx format, but from my limited knowledge I'd guess that the use of so called "sections" could answer Teodor's question about which header/footer to use, as each section of a docx can either inherit preceding headers and footers or define its own, so any subreport with either of those could trigger a section break and redefine the appropriate headers and footers. The following link may be a starting place:

Even if I needed to insert some kind of textual placeholder for fields like page#, page count, date etc. and had to replace those by manually executing a macro when opening the document, that would be fine for me, as it would still be a lot easier for my users than having to re-format everything and correct all the page numbers after inserting or removing content.

Converting Jasper's builtin fields to matching docx field expressions is a step that's probably too complicated as to hope for a quick solution, as I can see that constraints like variable evaluation time can give the programmer taking that on a big headache.




We have the exact same issue.
We need to generate docx letters that users can modify to add some text, but the footer moves when the text is added.

I agree with bitpoet, that just having the possibility to create real docx headers and footers would be a big step and more than sufficient, even without having an automatic page number placeholder.

Thanks and regards


  • Status:Feedback Requested» Acknowledged


We use batch export and managed to replace page number elements (with certain predefined key = PAGE_NUMBER)
by actual page number in the code before report filling

But we have the exact same issue, we don't need reflow page footers when somebody enters minor changes which doesn't modify document page count

What is an estimate for this improvement?


Hi Teodor,
Any updates on this? Is there any way of having fixed headers and footers so that even when text is added headers and footers stay unchanged? And in case a new page is created, header and footer are automatically inserted?



Any news on having a proper page headers and footers to docx? This will be a great feature to have when exporting docx reports.