com.itextpdf.layout.Style

Demo 样式的复用

// 样式的复用
Style normal = new Style()
normal.setFont(basefont).setFontSize(9)

Style code = new Style()
code.setFont(basefont).setFontColor(ColorConstants.RED).setBackgroundColor(ColorConstants.LIGHT_GRAY)

paragraph.add((new Text("Hello")).addStyle(normal))
paragraph.add(new Text("我是爸爸").addStyle(normal))

Demo cellStyle

// 创建对象
Style cellStyle = new Style()
// 设置内嵌Element的垂直位置
cellStyle.setVerticalAlignment(VerticalAlignment.MIDDLE)
// Element 内部文本对象的 Alignment 的对其方式
cellStyle.setTextAlignment(TextAlignment.CENTER)
原文地址:https://www.cnblogs.com/duchaoqun/p/13967595.html