Inline PDF Previews

Tried that, set cors origins to
also set DISCOURSE_ENABLE_CORS: true in the /var/discourse/containers/app.yml
but it’s not working.

1 Like

And you did a ./launcher rebuild app after making changes to app.yml? You might also need to do a browser hard refresh.


Incidentally, you might check the files section of the admin settings to see if you changed settings that are affecting this feature. I also don’t think this feature can be expected to work if you are linking to a PDF hosted on another server. I just tested this on my site and the same PDF served remotely did not show the preview.

Let us know if you find the source of the problem!

Sample markdown of post where remote did not work but uploaded locally did work.


[test remote pdf](

uploaded locally: 

[sample-pdf-with-images.pdf|attachment](upload://uOJLgHidEXnbqPRn2p6yP10ecQU.pdf) (3.8 MB)

how it looks:


yes. but it didn’t work.

When you enable S3 in Discourse

Then by definition the files are stored on a different domain.
I guess that clears the problem. But I still hope the plugin could be made to support Discourse installations that have S3 enabled.


I am not so familiar with this configuration. Did you follow these instructions?

1 Like

Yes, I have the S3 (and the related “secure media” setting) working for the last couple of years without a problem.
It is only the Inline PDF component that doesn’t work with this setting.

for reference, even setting app.yml like that:


doesn’t help


I ran into this exact problem too, and ended up reversing my S3 uploads just to get this TC to work as it is high value for us:

I really think that as this is official and S3 uploads are encouraged, this should be looked at to see if it can be made to work with S3 somehow. It could be that pdfs are specifically excluded from S3 uploads, but that would suck as some are enormous!


I don’t think anyone would disagree.
I’m guessing it’s about awareness and priorities.
At least regarding the “awareness” perhaps @Johani the OP could add a small note in the topic of this discussion that the inline PDF component doesn’t work with S3 enabled.
It would save others the time of troubleshooting and raise awareness to the issue.


There’s a bit of info about S3 in these posts I’ve fished out of the auto-timer if they’re any help?


A post was merged into an existing topic: Theme-Component Topics project

Yep, that works :smiley:
For reference if anyone else needs this:

  1. go to AWS console buckets and select the bucket that was used for your Discourse installation

  2. Choose the Permissions tab

  3. Scroll down to “Cross-origin resource sharing (CORS)” and write:

        "AllowedHeaders": [
        "AllowedMethods": [
        "AllowedOrigins": [
        "ExposeHeaders": []

Should look like this:


I wish I’d found that while I was still on S3 uploads!!

Might need to revisit it now. @JammyDodger, I wonder if that stuff should noted on both the S3 and this OP so others don’t trip up on this.


Absolutely. :+1: I was just waiting for some confirmation that it worked before thinking about how best to make an edit. :slightly_smiling_face:


Two ideas, adressing the same problem: the viewport of discourse is rather narrow, so most PDFs are too small to read inline. To adress this, we could

a) make the PDF-iframe resizable? I tried this with CSS already, but no no avail - the underlaying grid seems to be in the way
b) offer a second link “open in new tab” besides the download link? I am very keen on not downloading to much stuff from our forum.


This would be a marked improvement! And shouldn’t be too hard to add I think. Might have a go at a PR for this if I get the space over the next few days.


I think (b) is already provided as an option, eg inline vs open in new tab. Maybe a third option to let users see inline and open in new tab? I like this idea too.

(a) may be difficult given how hard it can be to get things to look right in a post.