I want to extract text present in header and footer.
As of now, I am doing something like this:
List<SectionWrapper> sectionWrappers = m_WordMLPackage.getDocumentModel().getSections();
for (SectionWrapper sw : sectionWrappers)
HeaderFooterPolicy hfp = sw.getHeaderFooterPolicy();
if (hfp.getDefaultHeader()!=null) System.out.println("-default");
HeaderPart hdp = hfp.getDefaultHeader();
System.out.println("Header part content : " + hdp.getContent());
List<Object> hdpList = hdp.getContent();
This gives me the content of the header. This returns a list of object, as seen above.
But how do I extract text from this list?
I know one way of extracting text from a paragraph by using getJAXBNodesViaXPath method and setting the xpath to "//w:r", but this method can only be applied on document part of the wordML package.
I have seen the samples present in docx4j, but they explain only about how to create and add a header/footer and not about extracting text from existing header part.
Eventually I want to modify the text present in this header/footer part.
Please, kindly help me in this situation.
Your help is greatly appreciated.