I'm new using Dox4j, and need some help to jump start using it. I'm trying to insert a page break in place defined by a tag like ${PAGE_BREAK}.
For that I'm using unmarshallFromTemplate like in the sample code :
- Code: Select all
// tag definition
HashMap<String, String> mappings = new HashMap<String, String>();
mappings.put("DATE", Calendar.getInstance().getTime().toString());
mappings.put("PAGE_BREAK", "<w:br w:type=\"page\" />");
// tag replacement
String doc = XmlUtils.marshaltoString(part.getJaxbElement(), true);
part.setJaxbElement((Document) XmlUtils.unmarshallFromTemplate(doc, mappings));
The problem is that no page break is inserted, DATE is well replaced. But concerning PAGE_BREAK, say I have in the original docx:
- Code: Select all
<w:p>
<w:r>
<w:t>${PAGE_BREAK}</w:t>
</w:r>
</w:p>
I'm lasting after template application with :
- Code: Select all
<w:p>
<w:r>
<w:t></w:t>
</w:r>
</w:p>
What is the right way to achieve this functionality. many thanks