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);
}
}
Aggregations