我要导出为PDF时出现错误消息

时间:2019-06-21 11:36:54

标签: asp.net vb.net

当我要将面板内容导出到pdf文档时,出现以下错误:System.UriFormatException:'无效的URI:Uri字符串太长。'

这是我在单击按钮时生成PDF的代码:

 Protected Sub btnCreatePDF_Click(ByVal sender As Object, ByVal e As EventArgs)

        Response.ContentType = "application/pdf"
        Response.AddHeader("content-disposition", "attachment;filename=Panel.pdf")
        Response.Cache.SetCacheability(HttpCacheability.NoCache)
        Dim sw As New StringWriter()
        Dim hw As New HtmlTextWriter(sw)
        PanelEmployeeMedicalHistory.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

0 个答案:

没有答案