可能引起关注的人:
我正在使用itextsharp将我的WebForm导出为PDF文件。我遇到的问题是只导出WebForm上可见的内容,即下拉列表的选定值。
下拉列表有3个值,AAA,BBB,CCC,当您选择AAA并导出为PDF时,它会显示PDF中的所有3个值,而不仅仅是下拉列表的选定值。
在导出按钮的代码下方:
Protected Sub btnExport_Click(sender As Object, e As EventArgs) Handles btnExport.Click
Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", "attachment;filename=TestPage.pdf")
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Dim sw As New StringWriter()
Dim hw As New HtmlTextWriter(sw)
'DropDownList1.Text = DropDownList1.SelectedValue
DropDownList1.RenderControl(hw)
'Me.Page.RenderControl(hw)
Dim sr As New StringReader(sw.ToString())
Dim pdfDoc As New Document(PageSize.A4, 10.0F, 10.0F, 100.0F, 0.0F)
Dim htmlparser As New HTMLWorker(pdfDoc)
PdfWriter.GetInstance(pdfDoc, Response.OutputStream)
pdfDoc.Open()
htmlparser.Parse(sr)
pdfDoc.Close()
Response.Write(pdfDoc)
Response.[End]()
End Sub
任何帮助将不胜感激