RTFTemplate - RTF 模板引擎


未知
跨平台
Java

软件简介

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);  
    }  
}