Attach PDFs as form media and open on tablet while offline

(Maybe this isn't really a showcase but just an ugly hack, admins please move as needed!)

Short version;
To attach PDFs to a form in Central and be able to view them on device in Collect (not Enketo):

  • put the PDF filename(s) in the big-image column in the survey or choices sheets
  • put a small JPG/PNG of the PDF, or just a generic pdf_icon.jpg in the image column
  • upload form then the required files to Central
  • on device, go to Settings, Apps, select whichever app is currently opening images as default, for me it was 'Gallery', select Set as default then under Open by default Clear defaults.
  • in Collect, tap on a small image, then when prompted, select your PDF viewer of choice (that can also view images) and it will open the PDF.
  • Caveats:
    • Does not work in Collect.
    • PNG/JPG zoom is lesser than system viewer.
    • Some image formats may not be supported in PDF viewer.
    • Two back (<) actions required to return to Collect when viewing image in PDF viewer

Long version:
I've been struggling with this for a while, I often have hundreds of PDFs that I need to make available as reference and for markup in my forms, usually technical drawings. Up to now I have converted these to PNG/JPG (PNG become illegible when viewed with the device viewer on Samsung tablets and JPG is better, even though it dithers and filesize suffers).

For markup, with the current image widget I still need to convert these to an image in order to load them into a question as a dynamic default.

For viewing, with the limited zoom no matter what the image resolution for big-image and poor rendered quality, plus the inflated file size for vector PDFs converted to 3000px images has been frustrating, especially when there is detail that can't be read at all on device when it's legible on desktop.

In the absence of a 'PDF' or 'binary' column (mentioned previously) to complement the image / big-image / audio / video columns, I tried putting the PDF filename in the video column, which caused it to appear in the required Form Attachments, however, unsurprisingly, neither Enketo nor Collect would open this.

I then put the PDF filename in the big-image filename. Enketo allows you to click the image but nothing renders and you can click to return. If you instead 'open in new tab' the PDF will download. Collect at first gave me a broken image in the Samsung gallery app, but I figured I could change the default to something that would handle image types plus PDF.

Resetting the default on my tablet and tapping the small image then gave me options of Gallery / Adobe Acrobat, selecting Acrobat then opened the PDF, allowing me to zoom far closer, and vector files didn't pixelate. :confetti_ball: :raised_hands:

Then, opening a JPG and a PNG, these both opened acceptably in Acrobat, albeit with lower zoom than the system viewer, and it does take two 'back' actions to return to Collect with images vs one with a PDF. A fair trade off for being able to view the source PDF.

4 Likes