我使用iTextSharp生成PDF。但问题是我的代码在c#中正常工作但是当我在vb中转换该代码时它会显示2个错误
请忽略一些额外的编码和评论 代码i使用
Dim Response As HttpResponse = SelectedGridView.Page.Response
Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", "attachment;filename=" & FileName)
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Dim sw As New StringWriter()
Dim hw As New HtmlTextWriter(sw)
SelectedGridView.RenderControl(hw)
Dim sr As New StringReader("<html><body>" & sw.ToString() & "</body></html>")
Dim pdfDoc As New Document(PageSize.A4, 10.0F, 10.0F, 10.0F, 0.0F)
Dim pdfWrite As PdfWriter = Nothing
pdfWrite = PdfWriter.GetInstance(pdfDoc, Response.OutputStream)
pdfDoc.Open()
Try
XMLWorkerHelper.GetInstance().ParseXHtml(pdfWrite, pdfDoc, sr)
Catch ex As Exception
End Try
'htmlparser.Parse(sr);
pdfDoc.Close()
Response.Write(pdfDoc)
Response.[End]()
和错误
上次修改图片:
我该怎么办?
答案 0 :(得分:0)
我有同样的问题。
我从http://sourceforge.net/projects/itextsharp/?source=typ_redirect下载了iTextSharp的dll文件,从http://sourceforge.net/projects/itextsharp/files/xmlworker/下载了xmlworker
提取它们并在解决方案资源管理器中右键单击解决方案,然后添加 - &gt;引用并在浏览选项卡中添加您的dll文件。