以下是我生成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]()