Export ASP.Net Repeater control with Image to PDF using C# and VB.Net

Last Reply one year ago By pandeyism

Posted one year ago

I have a panel that contains a repeater control with employee info and an image. When i want to export to a PDF then I get the following error:System.UriFormatException: System.Net.WebException: 'Could not find a part of the path 'C:\images\img_who-we-are_logo.png'.'

    Protected Sub btnCreatePDF_Click(ByVal sender As Object, ByVal e As EventArgs)
        Response.ContentType = "application/pdf"
        Response.AddHeader("content-disposition", "attachment;filename=TestPage.pdf")
        Dim sw As StringWriter = New StringWriter()
        Dim hw As HtmlTextWriter = New HtmlTextWriter(sw)
        imgLogo.Visible = True
        imgLogo.Visible = False
        Dim sr As StringReader = New StringReader(sw.ToString())
        Dim pdfDoc As Document = New Document(PageSize.A2, 10.0F, 10.0F, 100.0F, 0.0F)
        Dim htmlparser As HTMLWorker = New HTMLWorker(pdfDoc)
        PdfWriter.GetInstance(pdfDoc, Response.OutputStream)

    End Sub

This is my code for my image:                                              

<asp:Image ID="ImgLogo" runat="server" ImageUrl="~/images/img_who-we-are_logo.png" />


You are viewing reply posted by: pandeyism one year ago.
Posted one year ago

Hi Tevin,

Refer below link and implement with Repeater control.

Export ASP.Net DataList with Image to PDF using C# and VB.Net