0

I'm trying to view a PDF in my AppGyver app, but there are some problems with it. First of all, some notes:

  • The PDF can be accessed through a url to a php page which will generate the requested PDF file.
  • POST data must be sent when trying to access the url / PDF file (login credentials).
  • The PDF file is on an external web server.
  • The user must be able to go back to the last view.

I read about using steroids.views.PreviewFileView to view PDF files. Unfortunately it looks like this class is only supported on iOS and I would like to support Android too. The pdf can be accessed by clicking on a certain button.

I made this workaround, which creates a form by JavaScript and submits it immediately, when clicking on the button. Therefore I can request a file while sending post data and display it in the app. But when the PDF is loaded, the top part is displayed behind the navigation bar. When pinch-zooming the screen, the PDF file will be on screen entirely.

If I should use steroids.views.PreviewFileView, how can I send POST data to the url while trying to access the file? Or should I continue the way I solved it? Cause then I would like a little help with the solution on displaying the first page of the PDF entirely on loading it.

user229044
  • 232,980
  • 40
  • 330
  • 338
LaVomit
  • 492
  • 5
  • 15

1 Answers1

0

The steroids.views.PreviewFileView is not supported in the AppGyver Legacy Android Scanner, and seeing as that runtime is no longer in active development, will not be in the future either.

Viewing pdf's in Android WebViews in general is not exactly straightforward, but a common workaround seems to be to route it through Google Docs, as described in this answer. You should be able to adapt that for your use case as well (use it as the location attribute for a new WebView).

If you open the pdf in a new WebView, the user should be able to navigate back using the physical back button, so you could even just hide the navigation bar, if that is the only bothering you about the current workaround.

Community
  • 1
  • 1