Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Does anybody know if converting from html to pdf has a problem in displaying images.. .jpeg, or gif images? The code below i use to convert my page to a pdf but the pictures does not show:

Dim sr As StringWriter = New StringWriter()
HttpContext.Current.Server.Execute("Print.aspx", sr)
Dim htmlmessage As String = sr.ToString

Dim pdfBytes As Byte() = New HtmlToPdfConverter().GeneratePdf(htmlmessage)
Dim response As HttpResponse = Me.Response
response.Clear()
response.BufferOutput = True
response.AppendCookie(New HttpCookie("fileDownloadToken", String.Format("{0}{1}", customernumber, accountnumber)))
response.AddHeader("Content-Type", "binary/octet-stream")
response.AddHeader("Content-Disposition", "inline; filename=" + String.Format("{0}{1}.pdf", customernumber, accountnumber))
response.ContentType = "application/pdf"
response.BinaryWrite(pdfBytes)
HttpContext.Current.ApplicationInstance.CompleteRequest()
Catch ex As Exception
Posted

1 solution

I have faced similar problem while creating pdf using ASPOSE and passing html to it. As the little I remember it has to do with the path of the image inside the pdf.

PDF when read the images are copied locally at some path. not sure. Please check if this clue helps.

I guess you are getting X icon in the place of image
 
Share this answer
 
v2
Comments
Member 10736689 14-Apr-14 11:04am    
i just get an outline of the image.like a box.but its blank
Member 10736689 14-Apr-14 11:19am    
i specified the imageurl like this but it still is just showing a blank box
imgIdentification.ImageUrl = "~/logo.jpg"
Member 10736689 14-Apr-14 11:20am    
thank u so much its the way i specify the path, add to specify it like this to get it to work
imgIdentification.ImageUrl = C:\Users\Whitney.BEL.COM.BZ\Documents\Visual Studio 2010\Projects\CustomerCareElectronicForm\CustomerCareElectronicForm\logo.jpg
Member 10736689 15-Apr-14 11:46am    
i am still having a problem, if i specify the image url through the designer it works but if i dynamically set it at page load it doesnt work. any ideas why?
sudeepvajrala4114 17-Apr-14 7:11am    
Please share your code here. We can help

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900