我设计了.aspx页面,我正在尝试为我的页面生成PDF但是它显示“adobe reader无法打开,因为文件已经损坏”下面我粘贴了generatePDF的代码供您参考。请帮助我
Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
''// Verifies that the control is rendered
End Sub
Private Sub btnPdf_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPdf.Click
Dim Response As System.Web.HttpResponse = System.Web.HttpContext.Current.Response
Try
Dim parag As Paragraph = Nothing
Dim pdfPath As String = Server.MapPath("") & "\test.pdf"
If File.Exists(pdfPath) Then
File.Delete(pdfPath)
End If
Response.Clear()
Response.Buffer = True
Response.AddHeader("content-disposition", "attachment;filename=test.pdf")
Response.ContentEncoding = System.Text.Encoding.UTF7
Response.ContentType = "application/pdf"
Dim oStringWriter As New System.IO.StringWriter
Dim oHtmlTextWriter As New System.Web.UI.HtmlTextWriter(oStringWriter)
home.RenderControl(oHtmlTextWriter)
Response.Output.Write(oStringWriter.ToString())
Response.Flush()
Response.End()
Catch ex As Exception
End Try
End Sub