Wednesday, 4 September 2013

add data URI images PDF using itextsharp

add data URI images PDF using itextsharp

can can i add data url image to the pdf. it work fine if i have the
physical image but not with url
here is my code which i am passing normal image. but if i replaced the src
to dataurl it doesn't show at all.
Dim savePath As String = Server.MapPath("")
Dim html As String = "<!DOCTYPE
html><html><head></head><body><h1>Table Header </h1><table
border='1' cellpadding='5' cellspacing='0' style='width:
950px; font-size:10px;'><tr><th scope='row' style='text-align:
left;' colspan='4'><b>first Image</b></th><td> "
html += "<img width='32px' src='" & Server.MapPath("../images/yes.png") &
"' /> </td></tr></table></html>"
htmltopdf(html, savePath)
Sub htmltopdf(ByRef htmltext As String, ByRef filepath As String)
Dim doc As New Document(PageSize.A4, 80, 50, 30, 65)
Dim PFDStringName As String = "dfsg"
Dim pdfname As String = filepath & "/" & PFDStringName & ".pdf"
Try
Using PdfWriter.GetInstance(doc, New FileStream(pdfname,
FileMode.Create))
doc.Open()
Dim hw As New
iTextSharp.text.html.simpleparser.HTMLWorker(doc)
hw.Parse(New StringReader(htmltext))
End Using
Catch ex As Exception
Finally
doc.Close()
End Try
End Sub
example of dataurl image (http://jsfiddle.net/Qjvb3/)

No comments:

Post a Comment