有这个文件吗?C:\Documents and Settings\Administrator\jbproject\pfd\a.html,你在命令行里直接打开试试先

解决方案 »

  1.   

    还是不行啊,,,明明有这个html,,求救啊,,
      

  2.   

    同意
    你在ie的地址栏打开C:\Documents and Settings\Administrator\jbproject\pfd\a.html,试试看有没有这个文件?
      

  3.   

    a.html 放在 SRC同级目录下
      

  4.   

    请问怎样在数据库里拿到数据,生成PDF啊,,,
       急啊,,,,老总要我在星期4前解决,,,,
      

  5.   

    这有个简单的小例子,你看一下,此方法是不用生成pdf文件的;数据你从数据库中取出来;
    你可以从网上一份pdf包的文档,一切都可以搞定了。
    <%@ page contentType="text/html; charset=utf-8" language="java" errorPage="" %>
    <%@ page import="java.io.*,java.awt.Color,com.lowagie.text.*,com.lowagie.text.pdf.*"%>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Untitled Document</title>
    </head><body>
    <%
    response.setContentType( "application/pdf" );
    Document document = new Document();
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    PdfWriter writer=PdfWriter.getInstance( document, buffer );
    document.open();
    document.add(new Paragraph("Hello World"));//Hello World是要输出到PDF的内容
    document.close();
    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 );
     }
    %></body>
    </html>