在服务器生成PDF,供windows客户端下载。内容是一个Action下面的Jsp页面。就像poi那样直接就生成word那样生产PDF。
3种方案
1.直接生产PDF
2.生成word,再转成PDF。
3.生产图片,再转成PDF。都没实现,请大家指点

解决方案 »

  1.   

    现在服务器生成pdf保存到摸个路径下,然后将路径传给jsp,jsp通过操作输出流就可以实现下载pdf了
    你要先下载itextpdf的jar包,csdn上就有http://download.csdn.net/detail/zhou18549838/3716854
    java生成pdf示例如下:
    import java.io.File;import java.io.FileOutputStream;import java.io.IOException;import com.itextpdf.text.Document;
    import com.itextpdf.text.Paragraph;
    import com.itextpdf.text.PageSize;
    import com.itextpdf.text.pdf.PdfWriter;public class MakePdfTest
    { private String att; public void makdPdf() throws IOException
    {
    final int margin = 12;
    String filePath = "c:/java_test/";
    String fileName = "aa.pdf";
    att = filePath + fileName;
    File file = new File(filePath);
    if (!file.exists())
    {
    file.mkdirs();
    }
    Document document = null;
    FileOutputStream fos = null;
    PdfWriter pdf = null;
    try
    {
    document = new Document(PageSize.A4, margin, margin, margin, margin);
    fos = new FileOutputStream(filePath + fileName);
    pdf = PdfWriter.getInstance(document, fos);
    document.open();
    String summary = "this is a pdf made bycode \n another line";
    document.addSubject("This is the result of a Test.");
    document.add(new Paragraph(summary));
    att = filePath + fileName;
    } catch (Exception e)
    {
    return;
    } finally
    {
    if (document != null)
    {
    document.close();
    }
    if (pdf != null)
    {
    pdf.close();
    }
    if (fos != null)
    {
    fos.close();
    }
    }
    } public static void main(String[] args)
    {
    MakePdfTest testMake = new MakePdfTest();
    try
    {
    testMake.makdPdf();
    System.out.println(testMake.att);
    } catch (IOException e)
    {
    e.printStackTrace();
    }
    }
    }
      

  2.   

    HTML 转成 PDF,据我所说目前还没有开源的产品,商品产品倒是不少!
      

  3.   

    楼主装个OPENOFFICE 在LINUX 那个东西有JAVACLIENT 直接调用可以将任何WORD转成PDF
      

  4.   


    目前Linux中使用打印到PDF功能已经可以直接输出PDFpdf虚拟打印机就可以了
      

  5.   

    http://download.csdn.net/detail/luo1983/4392518
      

  6.   

    1楼方案可行的,以前有做过,并且HTML中的图片也可以加载入PDF中。