I have a… problem. I have a WebView that so far was receiving an HTML that I could print using the PrintManager in Android. Basically, it would launch the system’s printing screen and there I could save it as a PDF or actually print it on a portable printer.
However, the backend decided to send a pdf file, instead. The code is complicated because this is more or less (more) legacy code and right now I’m calling
webView.loadUrl(OnlineEnrollmentRepositoryFactory.createRepository().termsAndConditionsWebPageUrl(), headers) to load the HTML (which is now a PDF).
The problem is that I can’t display the PDF in the WebView anymore, as it’s not an HTML. So we plan on getting rid of the WebView (or at least, set its visibility to GONE) and simply launch the printing screen as soon as the PDF has loaded in the now hidden WebView. But this doesn’t work: the printing screen keeps on saying “preparing to print” or something like that, forever.
How could I keep the current request (so that I’m using the same loadUrl() method to get the pdf instead of the former HTML) and then print it? This way I could get around refactoring the whole thing. Is it possible to get the PDF in the WebView and print it from there as soon as I get it?