中文版本的HelloWorld

显示效果:

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

 示例代码

package test.create.c01;

import iofd.io.util.FontUtil;
import iofd.layout.OfdDocument;
import iofd.layout.block.Paragraph;
import iofd.layout.block.paragraph.Text;
import test.create.TestDocUtil;

/**
 * 中文版的你好,世界示例
 * */
public class C0102CNHelloWorld {

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

	private void done() throws Throwable {
		String clzName = this.getClass().getSimpleName();
		System.out.println(clzName + " begin");
		OfdDocument doc = new OfdDocument();
		Paragraph p = new Paragraph();
		Text text = new Text("你好,世界!");
		/*
		 * 设置字体:微软雅黑
		 * */
		text.setFont(FontUtil.MSYH);
		p.add(text);
		doc.add(p);
		String fileName = TestDocUtil.getOfdFilePath(this.getClass());
		doc.save(fileName);
		System.out.println(clzName + " end");
	}
}