我目前正在开发一个自动投票系统。到目前为止,我们正在通过创建选举结果的 pdf 文件来计划我们系统中的一些存档功能。我正在尝试在我的系统中实现这行代码:
Response.Clear()
Response.Buffer = True
Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", "attachment;filename=student.pdf")
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Dim StringWriter1 As New StringWriter()
Dim HtmlTextWriter1 As New HtmlTextWriter(StringWriter1)
GridView1.RenderControl(HtmlTextWriter1)
Dim StringReader1 As New StringReader(StringWriter1.ToString())
Dim newDocument As New Document(PageSize.A4, 7.0F, 7.0F, 7.0F, 7.0F)
Dim HTMLWorker1 As New HTMLWorker(newDocument)
PdfWriter.GetInstance(newDocument, Response.OutputStream)
newDocument.Open()
HTMLWorker1.Parse(StringReader1)
newDocument.Close()
Response.Write(newDocument)
Response.End()
但由于某种原因,IDE 无法识别“响应”方法。我已经导入以下内容:
Imports iTextSharp.text
Imports iTextSharp.text.pdf
Imports iTextSharp.text.html
Imports iTextSharp.text.html.simpleparser