1
0
-1

Hi all,

For the form that I am currently working on, a requirement of the form is to preview pdf disclosures in a dialog.

We have tackled this using an iFrame in the dialog, which works pretty well for the desktop experience.


However, Android browsers do not ship out with the ability to render pdf previews, so when the iFrame is viewed on Android devices the pdf will automatically download. This functionality is not desired.

A workaround that I have tried and functions in the desired way is to use Google Doc's viewer. So for example, if mobile is detected, we will open this URL https://docs.google.com/viewerng/viewer?url=http://www.pdf995.com/samples/pdf.pdf in a new window instead of this URL for desktop http://www.pdf995.com/samples/pdf.pdf in an iFrame.

I wanted to get feedback from the community to see if this is a viable workaround or if this is something that should be avoided.


  1. Tim Stewart

    Your approach sounds OK to me. As Ben says it would be good to display the information as HTML, but if you already have the PDF generated and the final user experience of viewing the PDF on mobile works well (scaling, scolling etc.) then your approach may provide the quickest solution.

CommentAdd your comment...

2 answers

  1.  
    1
    0
    -1

    You will have a much simpler and neater solution if you create a HTML version of the PDF and just show that.

    There is also this: iframe issues on mobile devices

      CommentAdd your comment...
    1.  
      1
      0
      -1

      Hi Tyler.

      Maybe if you use an extra JS library like BOX you can fix your problem. They provide an PDF viewer that can be embeded in you app. It has support for mobile browsers.

      https://developer.box.com/docs/box-content-preview

      I hope this helps you with your problem.

      1. Tim Stewart

        If you go down this route be aware that the library is around 400kB. Try to avoid adding it as code in the form, but rather load it only when necessary, from their CDN.

      CommentAdd your comment...