Hi,
Does anyone have an idea how can we use DOCX4J APIs to protect the Header Part in a docx file?
Protecting the whole document is easy, but I am specifically looking to protect just the header part.
Body should be editable to the user.
I am using the below code, but it does not set set the header as read only.
WordprocessingMLPackage template = WordprocessingMLPackage.load(new File(inputFile));
BindingHandler bindingHandler = new BindingHandler(template);
List<SectionWrapper> sectionWrappers = template.getDocumentModel().getSections();
HeaderPart header = null;
for (SectionWrapper sw : sectionWrappers) {
HeaderFooterPolicy hfp = sw.getHeaderFooterPolicy();
if (hfp.getDefaultHeader() != null) {
header = hfp.getDefaultHeader();
bindingHandler.applyBindings(header);
System.out.println(XmlUtils.marshaltoString(header.getJaxbElement(),true, true));
}
}
Ayush