有一些pdfnet库,等,不知道对你有没有帮助。如果直接保存pdf的话。这个没有接触到。jfreereport也在学习啊。
解决方案 »
- 求这个Java EE期末考试试题
- oracle+java+图片处理?
- struts 如何遍历map
- struts-config.xml文件中配置JDBC数据源问题?
- 搞网络,会远离程序员朋友吗?
- 有关wsdl2java的问题!
- 请问各位 这个功能在struts1.1中如何实现?
- 删除Vector中的任意项如何写?附有代码。
- 从xml的Document获取文本,以及从文本parserDocument
- 用JB6编译程序的时候,哪怕我改动一点,只想编译一下,它也会用EJBC,我能屏蔽掉EJBC吗???
- 在weblogic8.1下用xmlbeans读取xml文件出错???在线等!!!感激!!!
- 模糊搜索中的问题!
而JasperReport可以生成很多种文件格式的报表,其中包括pdf格式,它使用
生成pdf格式报表的引擎是iText,所以JFreeReport跟iText没有可比性
另外一种就是直接使用JasperReport的API生成报表,然后输出成PDF.这些都主要针对
报表而言的,如果只是一般的文档,那就可以直接使用Itext啦
import java.io.IOException;import com.lowagie.text.*;
import com.lowagie.text.pdf.PdfWriter;
public class HelloWorld { /**
* Generates a PDF file with the text 'Hello World'
*
* @param args no arguments needed here
*/
public static void main(String[] args) { System.out.println("Hello World"); // step 1: creation of a document-object
Document document = new Document();
try {
// step 2:
// we create a writer that listens to the document
// and directs a PDF-stream to a file
PdfWriter.getInstance(document,
new FileOutputStream("HelloWorld.pdf")); // step 3: we open the document
document.open();
// step 4: we add a paragraph to the document
document.add(new Paragraph("Hello World"));
} catch (DocumentException de) {
System.err.println(de.getMessage());
} catch (IOException ioe) {
System.err.println(ioe.getMessage());
} // step 5: we close the document
document.close();
}
}