Inline PDF Previews

Is this a plugin or component?

I was not able to achieve the desired behaviour with a component.

3 Likes

You can see that it’s a plugin by looking at the GitHub repo. If there’s a .rb file, it’s a plugin :slight_smile:

image

3 Likes

I know. But with iPad and the Hub is much easier to ask than start jumping around and then browsing GitHub. But the main reason is not pure lazyness (this time…), but iPad will be low in memory and the OS kills DiscourseHub.

But sure — telling .rb-trick is generally more informatic and useful way.

I could trust on @Thoka when said in the beginning it is a plugin, but for some really strange reason I didn’t that.

1 Like

Does this require the theme component or works without?

1 Like

You don’t need the theme. It works without. There are also no configuration options. Once installed, every PDF will be readable right in the browser.

2 Likes

Awesome thank you snd thanks for creating this new plugin. :vulcan_salute::sunglasses::+1:

2 Likes

@thoka Teeeeee-rrrrrrrriffffffic!!! Thank you so much!!! :derek_pointing: :bouquet: :sparkling_heart:

3 Likes

First thing to say is that the component works perfectly fine for me with S3, displaying inline previews.

One of our forum members has a particularly risk-averse approach to the internet. He’s using Firefox with the application behaviour setting changed to download PDF files rather than displaying in the browser.

When he opens up a particular topic where the PDF has previously been uploaded, Firefox automatically downloads the file every time. He’s technically competant, though I can’t vouch for his skills or experience, and has already tried this:

Overriding the CSS client side with “iframe.pdf-preview { display: none!important; }” hides the ‘preview’ but Firefox still downloads the blob.

The obvious answer is to change the browser setting to preview the file in Firefox but it’s not my place to tell others how to maintain their own security profile online, at least not without trying to find another solution. Any ideas?

1 Like

You could create another theme that s user selectable and not include the theme component on that theme. The user would need to select the theme from their profile.

4 Likes

That’s an interesting workaround but perhaps somewhat ‘throwing the baby out with the bath water’. :slightly_smiling_face:

They do have a choice to use the Redditish theme. Pretty much everyone seems to want to stay with the familiar. I will keep it in mind.

1 Like

You’re dealing with a user who is intentionally breaking your site and then complaining about it. If he doesn’t want inline pdf how is giving him the opportunity not to have them throwing anything away?

2 Likes

He’s complaining about the repeated downloading of a PDF that’s a conseqence of his choice of his preferred browser settings. On the basis of ‘you can’t please all of the people all of the time’, he’ll have to live with this one.

Nothing he’s doing will break the site for anyone else. If he finds a way to make something work for himself I’d call that a legitimate hack.

3 Likes

Hi,

Is there any update about new tab?

Thanks.

1 Like

We are using Discourse send PDF inline to read locally uploaded PDFs in the browser.

5 Likes

hi
this is my PDF preview

this is console errors

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://cdn.my_site.com/original/1X/0d281938d3ff2377541704cab6ba1c4408420733.pdf. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 200.

the problem there is an image work 100%
https://cdn.my_site.com/optimized/1X/b8e363026da621558d8c2a8159a4a7671eaf0285_2_1035x685.jpeg

this PDF link with broken preview
https://my_site.com/uploads/short-url/1So7iQsrmIZKLQ6UGI86B1cOqD9.pdf

i am using CloudFront as CDN.

here is s3 setting

my site S3 
[
   {
       "AllowedHeaders": [
           "*"
       ],
       "AllowedMethods": [
           "GET"
       ],
       "AllowedOrigins": [
           "http://my_site.com",
           "https://my-test-site.site",    # my test site use the same bucket.
           "https://cdn.my_site.com",
           "https://URL.cloudfront.net"
       ],
       "ExposeHeaders": [
           "Access-Control-Allow-Origin"
       ]
   }
]

i am missing something here…

1 Like

Take a look at the cors origin admin setting.

1 Like

i did add my cdn.my_site to cors origin

/admin/site_settings/category/all_results?filter=cors origin

or did you mean something else!

3 Likes

That is what I meant. If that did not fix it for you then you will have to dig further. There is some discussion in this topic please search for it and let us know how it goes! We could then update the first post with a solution.

3 Likes

I did fix it, But almost lost my mind.

I did tons of “rebuild the app” and once reinstalled the Ubuntu it self. Not sure what was wrong. In the process did fix upload assets to AWS S3.

Then i kept tying with the same PDF in the same topic :angry: :angry: with no solution.

Finally i give up, and later did upload PDF to other topic and it’s work.

1 Like