Search in sources :

Example 1 with Br

use of org.docx4j.wml.Br in project docx4j-template by vindell.

the class Docx4J_例子2 method addPageBreak.

// 分页
public void addPageBreak(WordprocessingMLPackage wordMLPackage, ObjectFactory factory, STBrType sTBrType) {
    MainDocumentPart documentPart = wordMLPackage.getMainDocumentPart();
    Br breakObj = new Br();
    breakObj.setType(sTBrType);
    P paragraph = factory.createP();
    paragraph.getContent().add(breakObj);
    documentPart.addObject(paragraph);
}
Also used : Br(org.docx4j.wml.Br) P(org.docx4j.wml.P) MainDocumentPart(org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart)

Example 2 with Br

use of org.docx4j.wml.Br in project docx4j-template by vindell.

the class Docx4J_简单例子2 method addPageBreak.

// 分页
public void addPageBreak(WordprocessingMLPackage wordMLPackage, ObjectFactory factory) {
    MainDocumentPart documentPart = wordMLPackage.getMainDocumentPart();
    Br breakObj = new Br();
    breakObj.setType(STBrType.PAGE);
    P paragraph = factory.createP();
    paragraph.getContent().add(breakObj);
    documentPart.addObject(paragraph);
}
Also used : Br(org.docx4j.wml.Br) P(org.docx4j.wml.P) MainDocumentPart(org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart)

Example 3 with Br

use of org.docx4j.wml.Br in project docx4j-template by vindell.

the class Docx4j_工具类_S3_Test method addPageBreak.

/**
 * @Description: 段落添加Br 页面Break(分页符)
 */
public void addPageBreak(P para, STBrType sTBrType) {
    Br breakObj = new Br();
    breakObj.setType(sTBrType);
    para.getContent().add(breakObj);
}
Also used : Br(org.docx4j.wml.Br)

Example 4 with Br

use of org.docx4j.wml.Br in project docx4j-template by vindell.

the class Docx4j_工具类_S3_Test method setParaRContent.

/**
 * @Description: 设置段落内容
 */
public void setParaRContent(P p, RPr runProperties, String content) {
    R run = null;
    List<Object> rList = p.getContent();
    if (rList != null && rList.size() > 0) {
        for (int i = 0, len = rList.size(); i < len; i++) {
            // 清除内容(所有的r
            p.getContent().remove(0);
        }
    }
    run = new R();
    p.getContent().add(run);
    if (content != null) {
        String[] contentArr = content.split("\n");
        Text text = new Text();
        text.setSpace("preserve");
        text.setValue(contentArr[0]);
        run.setRPr(runProperties);
        run.getContent().add(text);
        for (int i = 1, len = contentArr.length; i < len; i++) {
            Br br = new Br();
            // 换行
            run.getContent().add(br);
            text = new Text();
            text.setSpace("preserve");
            text.setValue(contentArr[i]);
            run.setRPr(runProperties);
            run.getContent().add(text);
        }
    }
}
Also used : Br(org.docx4j.wml.Br) R(org.docx4j.wml.R) Text(org.docx4j.wml.Text)

Example 5 with Br

use of org.docx4j.wml.Br in project docx4j-template by vindell.

the class AddingPageNrToFooter method addPageBreak.

/**
 * Adds a page break to the document.
 *
 * @param documentPart
 */
private static void addPageBreak(MainDocumentPart documentPart) {
    Br breakObj = new Br();
    breakObj.setType(STBrType.PAGE);
    P paragraph = factory.createP();
    paragraph.getContent().add(breakObj);
    documentPart.getJaxbElement().getBody().getContent().add(paragraph);
}
Also used : Br(org.docx4j.wml.Br) P(org.docx4j.wml.P)

Aggregations

Br (org.docx4j.wml.Br)13 P (org.docx4j.wml.P)9 MainDocumentPart (org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart)5 R (org.docx4j.wml.R)5 Text (org.docx4j.wml.Text)5 IOException (java.io.IOException)2 JAXBException (javax.xml.bind.JAXBException)2 Docx4JException (org.docx4j.openpackaging.exceptions.Docx4JException)2 JAXBPageTranscript (eu.transkribus.core.model.beans.JAXBPageTranscript)1 TrpPage (eu.transkribus.core.model.beans.TrpPage)1 TrpTranscriptMetadata (eu.transkribus.core.model.beans.TrpTranscriptMetadata)1 CustomTag (eu.transkribus.core.model.beans.customtags.CustomTag)1 CustomTagList (eu.transkribus.core.model.beans.customtags.CustomTagList)1 RegionType (eu.transkribus.core.model.beans.pagecontent.RegionType)1 TextLineType (eu.transkribus.core.model.beans.pagecontent.TextLineType)1 TrpPageType (eu.transkribus.core.model.beans.pagecontent_trp.TrpPageType)1 TrpRegionType (eu.transkribus.core.model.beans.pagecontent_trp.TrpRegionType)1 TrpTableCellType (eu.transkribus.core.model.beans.pagecontent_trp.TrpTableCellType)1 TrpTableRegionType (eu.transkribus.core.model.beans.pagecontent_trp.TrpTableRegionType)1 TrpTextLineType (eu.transkribus.core.model.beans.pagecontent_trp.TrpTextLineType)1