use of org.docx4j.model.structure.SectionWrapper in project docx4j-template by vindell.
the class Docx4J_简单例子 method createHeaderReference.
public void createHeaderReference(WordprocessingMLPackage wordprocessingMLPackage, MainDocumentPart t, ObjectFactory factory, Relationship relationship) throws InvalidFormatException {
List<SectionWrapper> sections = wordprocessingMLPackage.getDocumentModel().getSections();
SectPr sectPr = sections.get(sections.size() - 1).getSectPr();
// There is always a section wrapper, but it might not contain a sectPr
if (sectPr == null) {
sectPr = factory.createSectPr();
t.addObject(sectPr);
sections.get(sections.size() - 1).setSectPr(sectPr);
}
HeaderReference headerReference = factory.createHeaderReference();
headerReference.setId(relationship.getId());
headerReference.setType(HdrFtrRef.DEFAULT);
sectPr.getEGHdrFtrReferences().add(headerReference);
}
use of org.docx4j.model.structure.SectionWrapper in project docx4j-template by vindell.
the class Docx4J_简单例子 method createFooterReference.
public void createFooterReference(WordprocessingMLPackage wordprocessingMLPackage, MainDocumentPart t, ObjectFactory factory, Relationship relationship) throws InvalidFormatException {
List<SectionWrapper> sections = wordprocessingMLPackage.getDocumentModel().getSections();
SectPr sectPr = sections.get(sections.size() - 1).getSectPr();
// There is always a section wrapper, but it might not contain a sectPr
if (sectPr == null) {
sectPr = factory.createSectPr();
t.addObject(sectPr);
sections.get(sections.size() - 1).setSectPr(sectPr);
}
FooterReference footerReference = factory.createFooterReference();
footerReference.setId(relationship.getId());
footerReference.setType(HdrFtrRef.DEFAULT);
sectPr.getEGHdrFtrReferences().add(footerReference);
}
use of org.docx4j.model.structure.SectionWrapper in project docx4j-template by vindell.
the class Docx4J_简单例子2 method createFooterReference.
public void createFooterReference(WordprocessingMLPackage wordprocessingMLPackage, MainDocumentPart t, ObjectFactory factory, Relationship relationship) throws InvalidFormatException {
List<SectionWrapper> sections = wordprocessingMLPackage.getDocumentModel().getSections();
SectPr sectPr = sections.get(sections.size() - 1).getSectPr();
// There is always a section wrapper, but it might not contain a sectPr
if (sectPr == null) {
sectPr = factory.createSectPr();
t.addObject(sectPr);
sections.get(sections.size() - 1).setSectPr(sectPr);
}
FooterReference footerReference = factory.createFooterReference();
footerReference.setId(relationship.getId());
footerReference.setType(HdrFtrRef.DEFAULT);
sectPr.getEGHdrFtrReferences().add(footerReference);
}
use of org.docx4j.model.structure.SectionWrapper in project docx4j-template by vindell.
the class Docx4J_简单例子2 method createHeaderReference.
public void createHeaderReference(WordprocessingMLPackage wordprocessingMLPackage, MainDocumentPart t, ObjectFactory factory, Relationship relationship) throws InvalidFormatException {
List<SectionWrapper> sections = wordprocessingMLPackage.getDocumentModel().getSections();
SectPr sectPr = sections.get(sections.size() - 1).getSectPr();
// There is always a section wrapper, but it might not contain a sectPr
if (sectPr == null) {
sectPr = factory.createSectPr();
t.addObject(sectPr);
sections.get(sections.size() - 1).setSectPr(sectPr);
}
HeaderReference headerReference = factory.createHeaderReference();
headerReference.setId(relationship.getId());
headerReference.setType(HdrFtrRef.DEFAULT);
sectPr.getEGHdrFtrReferences().add(headerReference);
}
Aggregations