有一些pdfnet库,等,不知道对你有没有帮助。如果直接保存pdf的话。这个没有接触到。jfreereport也在学习啊。

解决方案 »

  1.   

    我一般是直接用iText+xml来搞定..
      

  2.   

    你用iText+xml,xml文件是作为模板文件来用吗?谢谢!
      

  3.   

    JFreeReport是只是一个定制报表格式的UI,它生成报表的引擎是JasperReport,
    而JasperReport可以生成很多种文件格式的报表,其中包括pdf格式,它使用
    生成pdf格式报表的引擎是iText,所以JFreeReport跟iText没有可比性
      

  4.   

    那么使用iText可不可以先制作好模板,然后再根据模板进行PDF文件的生成呢?谢谢!
      

  5.   

    没用过,呵呵,我只用过jasperreport 和 JFreeReport
      

  6.   

    用itext , 回家把代码粘出来
      

  7.   

    你使用jasperreport 和 JFreeReport,是不是事先制作好模板再读取模板文件来生成PDF文件呢?
      

  8.   

    有两种方式,第一种就是你说的使用所谓的模版文件,然后填充数据形成PDF文件,
    另外一种就是直接使用JasperReport的API生成报表,然后输出成PDF.这些都主要针对
    报表而言的,如果只是一般的文档,那就可以直接使用Itext啦
      

  9.   

    你可不可以给我一份关于JasperReport的使用文档,如何来定制模板后,填充数据形成PDF文件,谢谢!
      

  10.   

    package com.lowagie.examples.general;import java.io.FileOutputStream;
    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();
    }
    }
      

  11.   

    itext可以先定pdf模板后再通过程序向字段中填数据,楼主去itext网站查一下吧,我就这样做过,可惜那时候写的文章找不到了,我是先通过word画表格,再将word转成pdf后使用adobe acrobat(注意不是adobe acrobat reader)向pdf中加入字段信息,就和在vb/delphi中的gui设计器中放text输入框的过程类似,然后用itext读取pdf模板,填入数据就可以了,这种方式比较适合一个页面就是报表数据的一行的情况(如人员档案,一个页面就只是一个人员的信息),如果楼主是要用一个页面中有多行数据的情况,我看还是用jasperreport更方便一点,基本上现在我就是这两种结合起来用的.但上面我说的方法有一点问题,就是用itext直接处理时,一旦模板的样式要修改时还要先从word改起,改完后重新生成pdf,然后模板中的pdf字段数据要重新设计一次,有点麻烦.
      

  12.   

    你到http://jasperreports.sourceforge.net/下载源码,里面有很多例子。看看就会了。
      

  13.   

    我们公司是使用了一个叫SUPER VISUAL FORMADE的软件,来生成一个摸版,然后在JAVA 代码里面设置好这个摸版的路径,就可以按摸版的格式输出PDF文件~~~~