Hi all,
When converting an aspx page to pdf using itextsharp external css is not working.I dont want to create tables for exporting to PDf as its a complex design .I am able to generate the pdf but css is not getting applied. I am using the latest relese of itextsharp.dll.I ahve googled but not found a suitable solution.Can anyone guide me how to resolve this issue.
Protected Sub btnExport_Click(ByVal sender As Object, ByVal e As EventArgs)
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)
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
plz suggets
i m using above code but getting error:
htmlparser.Parse(sr)
is not defining proper path for the images:
Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Images\Layout\an-Logo.png'.
please suggest
Thanks in advance