1 post tagged “vb.net”
Since the documentation for SharpPDF is absolutely crappy and lacking, here is how I added a web-based image to a PDF.
objPDF is my pdfDocument, and odjPDFPage is my pdfPage.
Dim objWeb As New System.Net.WebClient
Dim objImg As System.Drawing.Image
objImg = System.Drawing.Image.FromStream(objWeb.OpenRead("http://blah.com/whatever.gif"))
objImg.Save("c:\temp.gif")
objPDF.addImageReference("c:\temp.gif", "logo")
objPDFPage.addImage(objPDF.getImageReference("logo"), 40, 730, 16, 100)
I'm temporarily putting it into the file system, which I still need to cleanup - but that's how you do it.
Note that SharpPDF needs the height and width to be halved, at least for my purposes - the image I'm using is really 200x32, e.g.