linux下使用itext输出pdf
来源:互联网 发布:淘宝盗图怎么电话投诉 编辑:程序博客网 时间:2024/04/29 02:46
还不错的open的pdf生成包,我用redhat EL5, tomcat5做到的试验
把下载来的 iTextAsian.jar 和 itext-2.0.4.jar放到tomcat的ROOT/WEB-INF/lib/下
然后用下面的jsp测试。就可以成功了输出日文的pdf了。
<%@
page import="java.io.*,
com.lowagie.text.*,
com.lowagie.text.pdf.*,
java.io.RandomAccessFile,
com.lowagie.text.Image"
%><%
//
// Template JSP file for iText
// by Tal Liron
//
page import="java.io.*,
com.lowagie.text.*,
com.lowagie.text.pdf.*,
java.io.RandomAccessFile,
com.lowagie.text.Image"
%><%
//
// Template JSP file for iText
// by Tal Liron
//
response.setContentType( "application/pdf" );
// step 1: creation of a document-object
Document document = new Document();
Document document = new Document();
// step 2:
// we create a writer that listens to the document
// and directs a PDF-stream to a temporary buffer
// we create a writer that listens to the document
// and directs a PDF-stream to a temporary buffer
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
PdfWriter.getInstance( document, buffer );
PdfWriter.getInstance( document, buffer );
// step 3: we open the document
document.open();
document.open();
// step 4: we add a paragraph to the document
String japanese = "/u5317/u672c/u3078/u884c/u304d/u307e/u3059/uff01";
BaseFont bfjapanese = BaseFont.createFont("HeiseiMin-W3","UniJIS-UCS2-H",BaseFont.NOT_EMBEDDED);
Font Fontjapanese = new Font(bfjapanese,12,Font.NORMAL);
Paragraph p = new Paragraph(japanese,Fontjapanese);
document.add(p);
String japanese = "/u5317/u672c/u3078/u884c/u304d/u307e/u3059/uff01";
BaseFont bfjapanese = BaseFont.createFont("HeiseiMin-W3","UniJIS-UCS2-H",BaseFont.NOT_EMBEDDED);
Font Fontjapanese = new Font(bfjapanese,12,Font.NORMAL);
Paragraph p = new Paragraph(japanese,Fontjapanese);
document.add(p);
// step 5: we close the document
document.close();
document.close();
// step 6: we output the writer as bytes to the response output
DataOutput output = new DataOutputStream( response.getOutputStream() );
byte[] bytes = buffer.toByteArray();
response.setContentLength(bytes.length);
for( int i = 0; i < bytes.length; i++ ) { output.writeByte( bytes[i] ); }
DataOutput output = new DataOutputStream( response.getOutputStream() );
byte[] bytes = buffer.toByteArray();
response.setContentLength(bytes.length);
for( int i = 0; i < bytes.length; i++ ) { output.writeByte( bytes[i] ); }
out.clear();
out = pageContext.pushBody();
%>
out = pageContext.pushBody();
- linux下使用itext输出pdf
- 使用iText输出PDF文件
- 使用iText输出PDF报表的实践
- iText使用入门,输出pdf到浏览器
- Java IText使用PDF模板 生成 输出PDF
- 【java】 iText使用PDF模板生成输出PDF
- 【java】 iText使用PDF模板生成输出PDF
- Java IText使用PDF模板 生成 输出PDF
- 我使用iText输出PDF报表的实践
- 使用iText输出PDF报表的实践(Z,有更改.)
- itext 输出多页PDF
- 生成pdf,使用itext
- 使用itext生成pdf
- 使用itext打印pdf
- Itext pdf 使用
- Itext导出PDF,linux下字体 不能显示的问题
- 【java】 iText使用PDF模板生成输出PDF 这个比较清晰
- 使用iText操作pdf文件
- javamail邮件内容提取
- 实现一个读取UTF-8文本文件的类
- 线程本地存储(Thread Local Storage, TLS)
- 给弱智的javascript添加trim方法
- BugZilla研究
- linux下使用itext输出pdf
- PHP - Manual手册 - V. Array 数组函数 - reset将数组的内部指针指向第一个单元
- 硬件还是软件?
- 获取查询字符串
- 线程本地存储 (TLS)
- test
- tomcat 连接 mysql
- J2EE学习笔记二:配置一个简单的J2EE测试环境
- 使用jsp的时候getOutputStream错误(转载)