Search in sources :

Example 6 with SectionWrapper

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);
}
Also used : SectionWrapper(org.docx4j.model.structure.SectionWrapper) HeaderReference(org.docx4j.wml.HeaderReference) SectPr(org.docx4j.wml.SectPr)

Example 7 with SectionWrapper

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);
}
Also used : SectionWrapper(org.docx4j.model.structure.SectionWrapper) FooterReference(org.docx4j.wml.FooterReference) SectPr(org.docx4j.wml.SectPr)

Example 8 with SectionWrapper

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);
}
Also used : SectionWrapper(org.docx4j.model.structure.SectionWrapper) FooterReference(org.docx4j.wml.FooterReference) SectPr(org.docx4j.wml.SectPr)

Example 9 with SectionWrapper

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);
}
Also used : SectionWrapper(org.docx4j.model.structure.SectionWrapper) HeaderReference(org.docx4j.wml.HeaderReference) SectPr(org.docx4j.wml.SectPr)

Aggregations

SectionWrapper (org.docx4j.model.structure.SectionWrapper)9 SectPr (org.docx4j.wml.SectPr)8 FooterReference (org.docx4j.wml.FooterReference)5 HeaderReference (org.docx4j.wml.HeaderReference)3 URISyntaxException (java.net.URISyntaxException)1 Inline (org.docx4j.dml.wordprocessingDrawing.Inline)1 PageDimensions (org.docx4j.model.structure.PageDimensions)1 Docx4JException (org.docx4j.openpackaging.exceptions.Docx4JException)1 BinaryPartAbstractImage (org.docx4j.openpackaging.parts.WordprocessingML.BinaryPartAbstractImage)1 TocException (org.docx4j.toc.TocException)1 org.docx4j.wml (org.docx4j.wml)1