Hello!
I want to convert an image to pdf and I want to send this image to a server.
I can create a pdf document, but i cannot send it to a server.
I don't know if I use good code and good object.
Thank you for your help.
I want to convert an image to pdf and I want to send this image to a server.
I can create a pdf document, but i cannot send it to a server.
I don't know if I use good code and good object.
Thank you for your help.
B4X:
private Sub uploadPicture
Dim newimage As Bitmap
Dim rect As Rect
Dim pdf As PdfDocument
Dim req As HttpRequest
Dim reqClient As HttpClient
Dim size As Long
pdf.Initialize
newimage = LoadBitmapResize(File.DirRootExternal&"/Eyevu_data","1.png",680,920,True)
rect.Initialize(0,0,newimage.Width,newimage.Height)
pdf.StartPage(1, 1) 'A4 size
pdf.Canvas.DrawBitmap(newimage,rect, rect)
'Oncomment this line for test with text
' pdf.Canvas.DrawLine(2, 2, 593 , 840, Colors.Blue, 4)
' pdf.Canvas.DrawText("Hello", 200, 200, Typeface.DEFAULT_BOLD, 30 / GetDeviceLayoutValues.Scale , Colors.Yellow, "CENTER")
pdf.FinishPage
Dim out As OutputStream = File.OpenOutput(File.DirRootExternal, "1.pdf", False)
pdf.WriteToStream(out)
out.Close
pdf.Close
reqClient.Initialize("")
size = File.size(File.DirRootExternal, "1.pdf")
Dim InputStream1 As InputStream = File.OpenInput(File.DirRootExternal, "1.pdf")
Globals.last_url = Params.get_eyevu_url & "/mobint/setdocument.php?id="&"&cid="& clientId &"&jwt=" & Params.get_jwt_token
req.InitializePost(Globals.last_url, InputStream1, size)
reqClient.Execute(req, 1)
end Sub