Search in sources :

Example 1 with CTBackground

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

the class Docx4j_工具类_S3_Test method setDocumentBackGround.

/**
 * @Description: 设置页面背景色
 */
public void setDocumentBackGround(WordprocessingMLPackage wordPackage, ObjectFactory factory, String color) throws Exception {
    MainDocumentPart mdp = wordPackage.getMainDocumentPart();
    CTBackground bkground = mdp.getContents().getBackground();
    if (StringUtils.isNotBlank(color)) {
        if (bkground == null) {
            bkground = factory.createCTBackground();
            bkground.setColor(color);
        }
        mdp.getContents().setBackground(bkground);
    }
}
Also used : MainDocumentPart(org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart) CTBackground(org.docx4j.wml.CTBackground)

Aggregations

MainDocumentPart (org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart)1 CTBackground (org.docx4j.wml.CTBackground)1