Hi All.
I have this need. Save a PDF file using the GetString method instead of GetInputStream
The file is saved, but obviously they are different and above all of different sizes.
For example GetInputStream produces a 98kb file
For example GetString produces a 176kb file
Strings are not saved in the right way in the case of GetString, even using GetString2 ("UTF8")
Of course GetInputStream work.
***** FIRST METHOD GetInputStream
'***** SECOND METHOD GetString
Any Suggestion ??
Thank you very much
Marco
I have this need. Save a PDF file using the GetString method instead of GetInputStream
The file is saved, but obviously they are different and above all of different sizes.
For example GetInputStream produces a 98kb file
For example GetString produces a 176kb file
Strings are not saved in the right way in the case of GetString, even using GetString2 ("UTF8")
Of course GetInputStream work.
***** FIRST METHOD GetInputStream
B4X:
'***** FIRST METHOD GetInputStream
Dim j As HttpJob
j.Initialize("", Me)
j.Download("https://www.axitech.it/sites/default/files/attachment/esempio_PDF.pdf")
'j.GetRequest.SetContentType("application/pdf")
'j.Download($"${addr}"$)
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Dim risultato As InputStream = j.GetInputStream
Dim out As OutputStream = File.OpenOutput(File.DirApp, "documentgetinputstring.pdf", False)
File.Copy2(risultato, out)
out.Close
fx.ShowExternalDocument(File.GetUri(File.DirApp, "documentgetinputstring.pdf"))
End If
j.Release
' '****** FINE PARTE PDF
'***** SECOND METHOD GetString
B4X:
'***** SECOND METHOD GetString
'Da sito Web
Dim j As HttpJob
j.Initialize("", Me)
j.Download("https://www.axitech.it/sites/default/files/attachment/esempio_PDF.pdf")
'j.GetRequest.SetContentType("application/pdf")
'j.Download($"${addr}"$)
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Dim res As String
res = j.GetString2("UTF8")
'res = j.GetString
Log(res)
Dim risultato As InputStream = StringToInputStream(res)
Dim out As OutputStream = File.OpenOutput(File.DirApp, "documentgetstring.pdf", False)
File.Copy2(risultato, out)
out.Close
fx.ShowExternalDocument(File.GetUri(File.DirApp, "documentgetstring.pdf"))
End If
j.Release
' '****** FINE PARTE PDF
Any Suggestion ??
Thank you very much
Marco
Attachments
Last edited: