cleanup header to use variableReplace()
Posted: Thu Feb 11, 2016 1:25 am
hey folks,
first of all. great work. i'm using docx4j for few weeks now and i am stoked.
now the reason i'm posting...
i'm trying to replace some variables in head and body of my docx.
since i want to use placeholders, i do it with
to make sure this will work, i clean my docx with
everythink works great for the main document part but not for the header.
to replace text i'm also using variableReplace()
eg
but if there is any kind of proof error, markup, rsids etc. it doesn't work.
question:
is there any simple way to 'clean' my header?
thx in advance
first of all. great work. i'm using docx4j for few weeks now and i am stoked.
now the reason i'm posting...
i'm trying to replace some variables in head and body of my docx.
since i want to use placeholders, i do it with
- Code: Select all
variableReplace()
to make sure this will work, i clean my docx with
- Code: Select all
VariablePrepare.prepare()
everythink works great for the main document part but not for the header.
to replace text i'm also using variableReplace()
eg
- Code: Select all
List<SectionWrapper> sectionWrappers = wordMLPackage.getDocumentModel().getSections();
for (SectionWrapper sw : sectionWrappers) {
HeaderFooterPolicy hfp = sw.getHeaderFooterPolicy();
if (hfp.getDefaultHeader()!=null) {
hfp.getDefaultHeader().variableReplace(mappings);
}
}
but if there is any kind of proof error, markup, rsids etc. it doesn't work.
question:
is there any simple way to 'clean' my header?
thx in advance