靠右对齐

显示效果:

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

 示例代码

package test.create.c02;

import iofd.layout.OfdDocument;
import iofd.layout.block.Paragraph;
import iofd.layout.block.paragraph.Text;
import iofd.layout.contants.AlignmentType;
import test.create.TestDocUtil;

/**
 * 展示如何设置靠右对齐
 * */
public class C0206SetAlignRight {

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

	private void done() throws Throwable {
		String clzName = this.getClass().getSimpleName();
		System.out.println(clzName + " begin");
		
		String s = "靠右对齐显示";
		
		OfdDocument doc = new OfdDocument();
		Paragraph p = new Paragraph();
		Text text = new Text(s);
		p.add(text);
		/*
		 * 设置文字靠右对齐
		 * */
		p.setAlignment(AlignmentType.RIGHT);
		doc.add(p);
		
		String fileName = TestDocUtil.getOfdFilePath(this.getClass());
		doc.save(fileName);
		System.out.println(clzName + " end");
	}
}