RTFTemplateRTF 模板引擎

联合创作 · 2023-09-29 02:53

RTFTemplate 是一个用来生成 RTF 文档的 Java 模板引擎。

RTFTemplate 的体系结构

示例代码:

  public class RTFProjectTest extends AbstractUseCase {

protected void putContext(IContext context) {
/**
* Context of simply POJO
*/
context.put("date", new Date());
context.put("project", new Project("Jakarta Velocity"));

/**
* Context of list of POJO
*/
List developers = new ArrayList();
Developer developer = new Developer("Will Glass-Husain", "wglass@apache.org");
developer.addRole("Java Developer");
developer.addRole("Release Manager");
....
context.put("developers", developers );
}

public static void main( String[] args ) throws Exception {
RTFProjectTest usecase = new RTFProjectTest();
usecase.run("usecases/project/project_model.rtf");
usecase.saveRTFVelocity(true); // Save RTF file with velocity macro
// Display the XML fields
System.out.println(usecase.getXMLFields());
// Save XML fields into project_model.fields.xml file with update description
usecase.saveTransformedDocument("usecases/project/project_model.fields.xml" ,false);
}
}
浏览 6
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报