RTFTemplate的初步使用
一、模版制作
1 设计 *.fields.xml文件,在此文件中定义好你要填充的参数。
三、使用Map<String, Object> contextMap = new HashMap<String, Object>();contextMap.put("title", title); //标题contextMap.put("serialNumber",serialNumber); //事故编号//rtf生成工具RTFGenerator generator = new RTFGenerator();generator.setContextMap(contextMap);generator.run(rtfSource, rtfTarget);
四、注意事项
1 解析生成的rtf文件有可能是乱码,用文本编辑器将rtf模版文件打开,将
\f0\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;替换成\f0\dbch\charset0\fprq2 宋体; 保存