private Document document;
private BaseFont bfChinese;
public testWord() {
this.document = new Document(PageSize.A4);
this.document.setMargins(90, 90, 99, 72);
}
public void expStuInfo(HttpServletResponse response,
HttpServletRequest request,
HashMap<String, String> map) throws Exception {
ByteArrayOutputStream ba = new ByteArrayOutputStream();
String filepath="毕业设计(论文)任务书.doc";
// 建立一个书写器(Writer)与document对象关联,通过书写器(Writer)可以将文档写入到磁盘中
RtfWriter2.getInstance(this.document, ba);
this.document.open();
// 设置中文字体
this.setBfChinese(BaseFont.createFont(
"C:\\Users\\Admin\\Desktop\\精楷简体.ttf", BaseFont.IDENTITY_H,
BaseFont.NOT_EMBEDDED));
// 正文字体风格
Font contextFont = new Font(bfChinese, 6, Font.NORMAL);
Paragraph context = new Paragraph("");
// 设置行距
context.setLeading(10);
// 正文格式左对齐
context.setAlignment(Element.ALIGN_LEFT);
context.setFont(contextFont);
// 离上一段落(标题)空的行数
context.setSpaci
com.lowagie.text 导出数据为word文档
最新推荐文章于 2022-01-04 12:54:22 发布