Make PDFs open directly (not via download) by default

Currently, the core handling of PDFs is via a download:

allaboutcats.pdf (42.2 KB)

While this is very functional, it adds a couple of unnecessary steps for the most common use case: “I want to read this now” - especially on mobile devices.

The need to download / save something is very much secondary. Required sometimes, but usually the user just wants to read it and then move on.

The Inline PDF Previews TC addresses this by serving an inline PDF on desktop - and does this with aplomb. However, it misses these common situations:

  1. PDFs on mobile devices
  2. Multiple PDFs (due to visual clutter)
  3. Viewing PDFs in a full browser tab

Of note, there are other paths to downloading a PDF. They can be downloaded from a link directly (via right-click / context menu), or from within the browser-based PDF viewer that this TC serves.

Suggestion: open PDFs in browser by default

This little tweak solves both of these situations nicely, and simply key into the default behaviour for other links in Discourse. So with the proposed change:

  1. PDF links in mobile typically open in the same browser window
    • enables single tap viewing
  2. PDF links on desktop (i.e. above the inline PDF) open in a new tab
    • this allows one-click full tab viewing
  3. When inline behaviour is deliberately suppressed (by adding a space in the link text)
    • allows one-click viewing

I’ve wrapped these up into this PR:

2 Likes