设置文字背景色
示例代码
package test.create.c01;
import iofd.kernel.colors.OfdRgbColor;
import iofd.layout.OfdDocument;
import iofd.layout.block.Paragraph;
import iofd.layout.block.paragraph.Text;
import test.create.TestDocUtil;
/**
* 设置文字背景色示例
* */
public class C0116SetFontBackgroundColor {
public static void main(String[] args) throws Throwable {
C0116SetFontBackgroundColor o = new C0116SetFontBackgroundColor();
o.done();
}
private void done() throws Throwable {
String clzName = this.getClass().getSimpleName();
System.out.println(clzName + " begin");
OfdDocument doc = new OfdDocument();
String s;
Paragraph p;
Text text;
s = "这是设置文字背景色示例";
p = new Paragraph();
text = new Text(s);
text.setBackgroundColor(OfdRgbColor.RED);
p.add(text);
doc.add(p);
p = new Paragraph();
text = new Text(s);
text.setBackgroundColor(OfdRgbColor.lightPink);
text.setSize(24d);
p.add(text);
doc.add(p);
p = new Paragraph();
text = new Text(s);
text.setBackgroundColor(OfdRgbColor.crimson);
text.setSize(36d);
p.add(text);
doc.add(p);
p = new Paragraph();
text = new Text(s);
/*
* 设置文字背景色
* */
text.setBackgroundColor(OfdRgbColor.lavenderBlush);
text.setSize(48d);
p.add(text);
doc.add(p);
String fileName = TestDocUtil.getOfdFilePath(this.getClass());
doc.save(fileName);
System.out.println(clzName + " end");
}
}