-1

以下是我生成pdf的代码。我正在为pdf使用标签。代码没有给出任何错误,但 pdf 也没有生成。

    Dim flname As String = "FeedbackReport"
    Response.AddHeader("content-disposition", "attachment;filename=" & flname)
    Response.Cache.SetCacheability(HttpCacheability.NoCache)
    Dim sw As New StringWriter()
    Dim hw As New HtmlTextWriter(sw)

    Dim frm As New HtmlForm()

    rp.Parent.Controls.Add(frm)
    'GridView1.Parent.Controls.Add(frm);
    '  frm.Attributes("runat") = "server"
    frm.Controls.Add(rp)
    'frm.Controls.Add(GridView1);
    frm.RenderControl(hw)
    Dim sr As New StringReader(sw.ToString())

    ' Dim pdfDoc As New Document(PageSize._11X17, 35.0F, 35.0F, 30.0F, 30.0F)
    Dim pdfDoc As New Document(PageSize._11X17, 20.0F, 20.0F, 30.0F, 30.0F)
    FontFactory.RegisterDirectories()

    Dim htmlparser As New HTMLWorker(pdfDoc)
    PdfWriter.GetInstance(pdfDoc, Response.OutputStream)
    pdfDoc.Open()
    htmlparser.Parse(sr)
    pdfDoc.Close()
    Response.Write(pdfDoc)
    Response.[End]()
4

1 回答 1

0

使用 itextsharp 生成 pdf

http://sourceforge.net/projects/itextsharp/

演示见以下链接

http://www.codeproject.com/Questions/203481/HTML-convert-to-PDF-using-itextsharp

于 2013-09-12T08:09:58.810 回答