// 定义OutputSteam对象
OutputStream outputStream = null;
// 指定文件下载用到的名称
StringBuffer fileName = new StringBuffer("");
contractFileName.append("テスト");
contractFileName.append(".pdf");
// 重新设置response对象
response.reset();
// 设置响应页面的类型
response.setContentType("application/pdf");
// 指定文件下载的默认名
response.addHeader("Content-Disposition", "attachment;filename="
+ new String(fileName.toString()
.getBytes("MS932"), "iso8859-1"));// 日文转换
outputStream = response.getOutputStream();
// 定义Document对象
Document document = null;
// BaseFont object with FONT00.TTF
BaseFont baseFont = BaseFont.createFont("FONT00.TTF",BaseFont.IDENTITY_H, true);
// 创建document对象,设置纸张,位置左,右,上,下
document = new Document(PageSize.A4,30,30,30,30);
// 创建writer对象,
PdfWriter writer = PdfWriter.getInstance(document,outputStream);
// Set page event
writer.setPageEvent();
// Open the document
document.open();
// Create a multi column text
MultiColumnText multiColumnText = new MultiColumnText();
multiColumnText.addRegularColumns(document.left(),document.right(), 20,1);
Font font = new Font(baseFont, 60);
font.setSize(8);
font.setStyle(Font.NORMAL);
multiColumnText.addElement(new Phrase("afagg", font));
document.add(multiColumnText);
document.close();
// 刷新缓冲区
outputStream.flush();
大概写了下,不是特别全,根据自己情况修改。