I recently added a new plugin to Discourse which enables inline PDF previews in topics and replies. Users don’t need to do anything special to use this feature on their posts.
If you upload a PDF in the standard manner (using the :upload: tool) Discourse will show you a preview in the topic, once the post has been saved.
Data Protection Act 2018 ukpga_20180012_en.pdf (2.9 MB)
You can still of course download the PDF for viewing elsewhere or in full size.
Notes:
- This component will only work on desktop browsers. There’s very little benefit to showing the previews on mobile since everything will be so small and very hard to read. I haven’t tested it on tablets.
- This component uses the native browser implementation to render the PDFs, so the results will look different on different browsers.
- Also note that this respects the user’s browser preferences for rendering PDFs inline. So, if the user does not want to allow PDFs to render inline, they will see a ‘plugin blocked’ kind of message instead of the PDF.
- Further info Inline PDF Previews - theme-component - Discourse Meta