Discourse send PDF inline

AI-generated summary

In the Discourse Plugin category, user thoka introduced a plugin designed to serve local PDF uploads inline, allowing them to display directly in the browser rather than forcing a download. The plugin was created after a feature request to Discourse core received no response.

The discussion explored several technical aspects and comparisons:

  • Functionality vs. Themes: nathank asked how this differed from existing Theme Components, to which Canapin clarified that the plugin opens the PDF directly in the browser window, not embedded within a post element.
  • Compatibility: Jagster inquired about S3 and CDN support. thoka confirmed the plugin does not alter how S3 serves PDFs.
  • Stability: meglio questioned the plugin’s current status. thoka initially reported it was broken but later confirmed in post 12 that it is working as expected.
  • Mobile UX Concerns: thoka noted potential downsides, such as users exiting the Discourse Progressive Web App interface to view the PDF and reliance on specific browser behaviors (e.g., Chrome on Android often forces downloads).
  • Core Integration: ajschmidt suggested upstreaming the feature, but thoka reiterated that the plugin was necessary due to the lack of response to the original request.

The thread concluded with Canapin noting that the plugin is no longer needed, as Discourse has updated its core behavior to open PDFs directly by default.


Features

Uploaded PDFs are opened with “content disposition inline”, which allows them to be displayed in the browser instead of being offered for download.

Configuration

Not necessary.

5 Likes

How is this different / better than the existing Theme Component to do the same?

1 Like

The plugin directly opens the PDF in the browser, not in an embedded element inside a post :slight_smile:

This was a feature request: Add configuration option to serve local PDF uploads inline

2 Likes

Does local mean S3 and similar plus CDN will fail when using this plugin?

It does not alter the way, S3 serves PDFs.
Side effects would be magic.

4 Likes

Is this plugin still in a working condition?

We are still using it.

2 Likes

Unfortunately, it’s broken currently.
I have to investigate.

2 Likes

Maybe I’m naive, but I think most people would want PDFs to render in the browser by default.

@thoka, is there any reason you opted to publish a plugin for this functionality rather than trying to upstream it into Discourse?

I found time to test it.
The plugin is working as expected.
I do not understand, what might have caused problems in the meantime.

I wrote the plugin, since there were no responses to my feature request.

When thinking about drawbacks of sending PDFs to the browser directly, I envision the following potential issues:

When utilizing Discourse as a Progressive Web App on a mobile device, one inevitably exits the Discourse interface, or rather its user interface, to display the PDF, thereby relying on the user’s familiarity with navigating back to the original application.

Furthermore, when it comes to mobile devices, one is at the mercy of how the browser handles inline PDFs. While Firefox currently displays the file directly, it appears that there is no way to persuade Chrome to do so:

1 Like

Not needed anymore! :partying_face:

4 Likes