设置文字颜色

显示效果:

示例代码所生成的OFD文件:下载

 示例代码

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 C0107SetColor {

	public static void main(String[] args) throws Throwable {
		C0107SetColor o = new C0107SetColor();
		o.done();
	}

	private void done() throws Throwable {
		String clzName = this.getClass().getSimpleName();
		System.out.println(clzName + " begin");
		
		String s = "中国 China 版式文件 iOFD";
		OfdDocument doc = new OfdDocument();
		Paragraph p = new Paragraph();
		Text text = new Text(s);
		/*
		 * 设置文字颜色:红色
		 * */
		text.setColor(OfdRgbColor.RED);
		p.add(text);
		doc.add(p);
		
		String fileName = TestDocUtil.getOfdFilePath(this.getClass());
		doc.save(fileName);
		System.out.println(clzName + " end");
	}
}