package
com.csg.action;
import
java.awt.Color;
import
java.io.FileOutputStream;
import
java.io.IOException;
import
com.lowagie.text.Cell;
import
com.lowagie.text.Document;
import
com.lowagie.text.DocumentException;
import
com.lowagie.text.Element;
import
com.lowagie.text.Font;
import
com.lowagie.text.Image;
import
com.lowagie.text.PageSize;
import
com.lowagie.text.Paragraph;
import
com.lowagie.text.Phrase;
import
com.lowagie.text.Table;
import
com.lowagie.text.pdf.BaseFont;
import
com.lowagie.text.rtf.RtfWriter2;
import
com.lowagie.text.rtf.style.RtfFont;
public
class
WordTest2 {
public
void
createDocContext(String file)
throws
DocumentException,
IOException {
Document document =
new
Document(PageSize.A4);
RtfWriter2.getInstance(document,
new
FileOutputStream(file));
document.open();
BaseFont bfChinese = BaseFont.createFont(
"STSongStd-Light"
,
"UniGB-UCS2-H"
, BaseFont.NOT_EMBEDDED);
RtfFont titleFont =
new
RtfFont(
"宋体"
,
21
, Font.BOLD, Color.BLACK);
img.scalePercent(
50
);
img.scalePercent(
25
,
50
);
img.setRotation(
30
);
cell.add(img);
aTable.addCell(cell);
cell =
new
Cell(
new
Phrase(
"作品1:《文明符号迴响》"
, fontChinese));
cell.setBorderWidth(
0
);
aTable.addCell(cell);
cell =
new
Cell(
new
Phrase(
"作品2:《石语之一》"
, fontChinese));
cell.setBorderWidth(
0
);
aTable.addCell(cell);
cell =
new
Cell(
new
Phrase(
"落款:23/25 文明符号迴响 xxx 2009"
, fontChinese));
cell.setBorderWidth(
0
);
aTable.addCell(cell);
cell =
new
Cell(
new
Phrase(
"落款:7/15石语之一 石版画 xxx 2011"
, fontChinese));
cell.setBorderWidth(
0
);
aTable.addCell(cell);
document.add(aTable);
}
document.add(
new
Paragraph(
"\n"
+
"\n"
));
title =
new
Paragraph(
"作者简介"
);
title.setAlignment(Element.ALIGN_CENTER);
titleFont =
new
RtfFont(
"宋体"
,
16
, Font.BOLD, Color.BLACK);
title.setFont(titleFont);
title.setSpacingAfter(
10
);
document.add(title);
String contextString =
"xxx1969-年生于北京南靖,籍贯广东潮州。1996年毕业于广州美术学院版画系并留校工作, 现为广州美术学院版画系副教授,山西大学客座教授;中国美术家协会会员,中国美术家协会藏书票研究会常务副主席,广东青年画院画家。"
+
"多件作品入选全国美展、全国版画展、国际版画展等学术展。曾获第九届全国美术作品展优秀奖、当代中国青年作品展二等奖、国务院庆祝澳门回归祖国宣传招贴画十佳作品奖、全军廉政文化优秀作品展二等奖、广东省美术作品展铜奖、广东版画奖等学术奖项。"
+
" \n"
+
"作品、论文发表于《美术》、《美术观察》、《中国版画》、《美术学报》、《北方美术》等学术刊物。出版教材《石版画》、《版画》(合著)等 ;出版作品集《中锐xxx作品集》;入编《中国美术大事记》、《当代中国艺术》、《中国当代中青年版画家石版画精品集》等。"
+
" \n"
+
"作品被广东美术馆、神州版画博物馆、中华世纪坛、绍兴鲁迅纪念馆、观澜美术馆、汕头博物馆、广州美术学院、伊斯坦布尔国际版画馆等学术机构及个人收藏。"
;
Paragraph context =
new
Paragraph(contextString);
context.setAlignment(Element.ALIGN_LEFT);
context.setFont(contextFont);
context.setSpacingBefore(
10
);
context.setFirstLineIndent(
20
);
document.add(context);
document.close();
}
public
static
void
main(String[] args) {
WordTest2 b =
new
WordTest2();
try
{
b.createDocContext(
"d:/demo.doc"
);
System.out.println(
"导出成功"
);
}
catch
(DocumentException e) {
e.printStackTrace();
}
catch
(IOException e) {
e.printStackTrace();
}
}
}