How to Load a PDF in a Lightbox on Mobile Safari (and elsewhere)

PDF inside lightbox on an ipad

A lightbox—which opens on top of the site (or app) that you are currently viewing—is a great way to load external content, but remain on the same page once the content is closed.

As a designer, a lightbox is a useful tool to keep readers in your “experience” and not force them to find their way back to your page.

Technically speaking, a lightbox loads external content into an <iframe>.

in5 (InDesign to HTML5) let’s you add lightboxes with a single checkbox—no coding or hassle required (and no thinking about iframes)!

The Problem: iOS, Lightboxes, and Multipage PDFs

A handful of in5 customers found that when loading multipage PDFs into a lightbox on iOS devices (iPads and iPhones), you can’t navigate to the second page.

This happens in part because iOS has a PDF viewer built into the web browser.

Normally, the built-in PDF view is quite handy, but when it’s loaded into an iframe, you don’t have access to the page navigation.

Google Drive to the Rescue!

Fortunately, if you

  1. upload your PDF to Google Drive and
  2. grab a shareable link (details below)

The Google online PDF viewer will let you navigate through all the pages (even in a lightbox).

Simply replace the hyperlink to your PDF with the Google Drive shareable URL.

Other sharing services that can view PDFs online would probably work too (e.g., Dropbox), but you may want to factor in how much user interface (UI) and branding of the service itself adds around the document.

Details on How to Get the Shareable Link

  1. While previewing your PDF in Google Drive, go to the fly out menu in the top-right of the viewing window.
    embed under flyout menu
  2. Then grab only the URL portion from the Embed dialog (leave the HTML code).

embeddable URL

Google Drive will keep the UI minimal if you add &embedded=true to the end of the URL.

Original Source: http://stackoverflow.com/questions/15480804/problems-displaying-pdf-in-iframe-on-mobile-safari

Bonus Tip

You can also view files through the Google Docs viewer, even if they are external and not hosted on Google Docs, using the URL below:

https://docs.google.com/gview?url=EXTERNAL_URL_TO_YOUR_DOC

Get updates from Ajar Productions

Splittext id 400px

Sign up today and get the InDesign Split Text premium extension for free!

Unsubscribe at any time. Powered by ConvertKit
Justin | design,HTML5,tips | Monday, July 3rd, 2017

Leave a Reply

Your email address will not be published. Required fields are marked *