I want to put Pictures on a PDF.
I installed the MBS DynaPDF Plugin.
I can use this code, to place a picture to my PDF:
dim p as Picture = Bild_Logo
call pdf.InsertPicture(p, 232, 30, (465/4), (118/4))
No my problem:
The pictures aren’t in the Xojo -App SourceCode. The pictures are on a web server.
How can I add the pictures with an URL to the PDF?
I guess something like:
dim URLToPicture as String = “http://127.0.0.1/pictures/picture1.png ”
dim p as Picture.URL = URLToPicture
call pdf.InsertPicture(p, 232, 30, (465/4), (118/4))
You would need to download the image from the webserver with a HTTPSocket before using it in the PDF.
Save it in Temporary or Application Support.
If there was a way to embed a remote image in the PDF anyone opening it would need to have access to the web.
or use our CURL plugin to download picture.
I have the same problem.
@Tim :
I know how to download the images. But I don’t know, how I can say Xojo: Wait until the download is complete.
HTTPSocket and CURL plugin can run synchronously.
So function returns when download is ready.
David_Cox
(David Cox)
March 22, 2016, 4:04pm
6
Download the image using whatever means (HTTPSocket, curl, etc.) and then use Picture.FromData to convert the downloaded image data into a Xojo Picture object.
e.g.:
Function URLToPicture(URL As String) As Picture
Dim http As New HTTPSocket
Dim data As MemoryBlock = http.Get(URL, 5)
Return Picture.FromData(Data)
End Function