Android Question Download PDF File from web service.

Ing. Daniel Edelman

New Member
Licensed User
Hi, I need to consume a web service that returns a PDF file.
When invoking the URL in the browser, the file is downloaded.

I have tried with the described methods to download services from a web server but I end up getting the html code of the URL in a file.

Any idea that guides me as to how to access the PDF file instead of the HTML code of the page that invokes the web service is appreciated.

Greetings.
Sorry for my (Google translated) english.
Daniel
 

Ing. Daniel Edelman

New Member
Licensed User
When I type in the browser the url: http://laboratorio.maciel.asse.com.uy/modulab/intralab/ni/ShowReport/265540?hfdocumentformatid=73 I get the result of the download of the corresponding PDF file. If I invoke that url from b4a through an HttpJob1.Download (Url) or through DownloadManagerRequest, I get the xml code that the web page draws.

To access the url, you must first provide authentication by username and password. I do this process using the following Javascript code and it works correctly.


Javascript.Initialize

Javascript.Append("var form=document.forms[0];") ' this assumes your form is the first form on the page

Javascript.Append("form.username.value='" & str.trim(usuarios(indicador)) & "';")
Javascript.Append("form.password.value='" & str.trim(passwords(indicador)) & "';")
Javascript.Append("form.submit()")

Log("Executing javascript: "&Javascript.ToString)

WebViewExtras1.executeJavascript(WebView1, Javascript.ToString)

(I can pass to test, user and password in private communication).

Thank you so much.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…