创建文字水印

显示效果:

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

 示例代码

package test.create.c06;

import iofd.layout.DefaultPageProperty;
import iofd.layout.OfdDocument;
import iofd.layout.block.Paragraph;
import iofd.layout.block.paragraph.Text;
import iofd.layout.block.watermark.TextWaterMark;
import test.create.TestDocUtil;

/**
 * 
 * */
public class C0601WaterMark {

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

	private void done() throws Throwable {
		String clzName = this.getClass().getSimpleName();
		System.out.println(clzName + " begin");
		
		OfdDocument doc = new OfdDocument();
		DefaultPageProperty prop = DefaultPageProperty.createDefaultPageProperty();
		prop.setDebug(true);
		doc.setDefaultPageProperty(prop);
		
		Paragraph p = new Paragraph();
		p.add(new Text("在页面中创建文字水印"));
		doc.add(p);
		
		TextWaterMark mark = new TextWaterMark("机密");
		doc.add(mark);

		String fileName = TestDocUtil.getOfdFilePath(this.getClass());
		doc.save(fileName);
		
		System.out.println(clzName + " end");
	}
}