2

I use the docx4j for creating documents fed with XML data. The ContentControlBindingExtensions example shows how to use a simple for loop over the data to generate rows in invoice for each item from the XML file.

However, I can not find any way to repeat the whole page per each item (let's say my XML contains people and there should be one page per each person). When using the authoring add-in for Word (suggested here) I can't select the whole page to put the for loop on.

I thought I can insert a Page Break (Ctrl+Enter) at the end of the template and select it inside a for loop. However, this results in one empty line at the top of every page but the first.

Community
  • 1
  • 1
fracz
  • 20,536
  • 18
  • 103
  • 149

1 Answers1

1

You can put a hard page break (Word: Insert > Page Break) inside a rich text content control.

You can even put a Section Break inside a rich text content control, and this can be of type "Next Page".

So as long as your content is less than a page, you'll get a whole page per item.

JasonPlutext
  • 15,352
  • 4
  • 44
  • 84
  • As I wrote in a question, I tried with page break and it results in one empty line at the beginning of each page starting at 2. Now, I tried to insert the loop in the tepmlate more carefully (selecting the Page Break but not the character after) and the result is better. Generated docx has one page per item plus one extra blank page at the end. If there is nothing to do about it - I can live with it. Thank you! – fracz Jan 18 '16 at 14:48