#1 webview is not a browser. webview can do some (many) things that a
browser can. it also cannot do many things that a browser can do.
there are 2 ways you can get your .pdf from that site (which looks suspiciously
like the bank where i hide my offshore money from my ex-wife):
1) using okhttputils2.
2) using webview's print facility.
i have tested both. both work for me.
there are, potentially, issues with either approach. that you could not see
how to download the file by yourself makes me wonder how much
experience you have trying to resolve conflicts between browsers
and webview.
i have attached both versions. as i said, they both work for me today.
neither one may work tomorrow. you would have to be in a position to
be able to figure out what may have changed. i refer particularly to the
dynamic nature of random values used as parameters. sites often
change values they assign to identifying features.
the okhttputils2 version does not use a webview. a webview - or even a
browser - is not needed to download the pdf. in fact, as you have already
discovered, you are unable to download the file using a webview so it
serves no purpose here. in order to download the file, you need only know
how to make the request. i simply used the browser to tell me what i needed
to know in order to make an independent request to download a file from the
site. the information provided by the browser is definitely valid for the several
times i tested downloading the file on android using okhttputils2. generally,
changeable parameters tend to be different with each request. in this case,
they did not change when i tested. that could mean you might be able to
download the file successfully whenever you wanted. note: okhttputils2 has
a "success" variable which does not always mean what you think it means.
it means there was no error in the request transfer. it does not mean the
response from the server was what you asked for. you would have to see
what the server actually said.
the webview version loads the site in a webview and then uses android's built-in
functions to capture the page as a .pdf file. this is due to the webview's not
being able to handle the way the site provides for downloading files.
so, while you cannot download the file directly, you can "print" it to a .pdf file.
that is what the second version does. it's not as smooth nor as fast as the
okhttputils2 version, but it does the job, and it does not depend on knowing
certain information which is only available from looking at the site in a desktop
browser. printing has to be enabled on your device. you may or may not actually
have to have a wifi printer attached for this to work. i do, so it does. webview is
told to create a print job of the current page. it does this, and the next thing you
see is a printing dialog. you select "save to file", and the pdf is save in your
documents directory. i can tell you right now you will not be happy with the
quality of the .pdf. it is very small because an android screen is small. even if
you transfer the file to a pc for display, it is very small. the result obtained from
using okhttputils2 is much better. when you use the webview version, you have
to wait until the spinning wheel stops and you can see the page before tapping
the "download" button. although the page load quickly, rendering takes a few
seconds.
if i forgot to mention it, version1 (okhttputils2) puts the file in safedirexternal, which
you can see from a PC. method2 (webview) leaves the file in your root files or
documents folder, which you can also see from a PC (as well as from the device).
that's what android does with it. in method1, it would be possible to store the file
in documents too, but it involves a bunch of extra code which i didn't add. you can
search for that and add it yourself.