MihajloNesic / jekyll-pdf-embed

:page_facing_up: :pushpin: Jekyll plugin for embedding PDF and PowerPoint files to any page or post
https://mihajlonesic.gitlab.io/projects/jekyll-pdf-embed/
GNU General Public License v3.0
51 stars 2 forks source link

PDF is downloaded instead of displayed #6

Open jlconlin opened 2 years ago

jlconlin commented 2 years ago

I have page where I'm trying to embed a PDF like this:

{% pdf "/Meetings/Attachments/Agenda.pdf" %}

Instead of embedding the PDF in the page, the PDF is downloaded. There is some space for the embedded PDF, but it just shows a blank space instead.

Do I have something configured incorrectly?

MihajloNesic commented 2 years ago

That's strange. You are using the correct syntax. Is there anywhere I can see this live?

Until then, you can check out the official example usage page -> https://mihajlonesic.gitlab.io/jpe-examples/

jlconlin commented 2 years ago

@MihajloNesic Unfortunately, the page is not hosted externally. I have seen the example page, which helped.

Attached to this is my (edited) _config.yml. I just removed the personal things that I can't share. It "shouldn't" affect the issues I'm seeing.

_cfg.yml.txt

I know this plugin used to work. But now it seems that every post I have that embeds the PDF, now just downloads it instead.

MihajloNesic commented 2 years ago

@jlconlin Hmm, the config file didn't really help (thank you though). You probably did set it up correctly, as you said, it did use to work.

Does that mean that the server from which you are embedding the pdf files has changed? Maybe the Content-Disposition header changed?

I will try to recreate the issue (probably) this weekend. Thank you for your time and keep an eye on this issue :)

jlconlin commented 2 years ago

Oh, now you are getting beyond my area of expertise. I'm not a web developer. The machine is still the same. It's possible (likely?) that the theme I am using (minimal mistakes) was updated and that made a change.

MihajloNesic commented 2 years ago

Hello @jlconlin . I've made an example Jekyll website with theme Minimal mistakes and jekyll-pdf-embed. You can view the source code here https://github.com/MihajloNesic/minimal-mistakes-pdf-example or see the demo live here https://mihajlonesic.github.io/minimal-mistakes-pdf-example/jekyll-pdf-embed-test

The plugin works as expected. No automatic downloads

akbaritabar commented 2 years ago

I can confirm the same issue (view link is there but no PDF is shown, it downloads it instead of showing) using Mozilla/Firefox (latest version, on Mac) even with your website (photo below). It works perfectly fine when I open it in Google Chrome though.

In Mozilla/Firefox

image

In Chrome

image
MihajloNesic commented 2 years ago

Hi @akbaritabar, thank you for the screenshots.

That is a strange behaviour. I just tested on Firefox and Chrome (both latest versions) on MacOS and it works perfectly.

Firefox

Screenshot at Dec 31 10-15-29

Chrome

Screenshot at Dec 31 10-16-41

I think dumping the iframe is a priority for the next update.

akbaritabar commented 2 years ago

@MihajloNesic Thank you for letting me know. If this helps, I should add that for my own jekyll based blog I was doing my test while running the server locally and I had not yet pushed to GitHub pages (I see from your screenshot that you have already pushed to server). But for the case of your website (the screenshots in my previous comment), these were indeed strange behavior.

jlconlin commented 2 years ago

Any word on how to fix this? I can confirm that this is an issue using Firefox on my Mac, but it works using Chrome on my Mac.

hosseinabdinf commented 2 years ago

Hey @MihajloNesic, @jlconlin I have the same issue when I use an external pdf link from Github! everything works fine when I test the plugin with your example link as below: {% pdf "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf" %}

But when I use an external link (from Github), the browser suddenly starts downloading the PDF file. I ran my Jekyll website locally, and I tested the output on Google Chrome and Microsoft Edge, both of them started to download the PDF file.

here is my code: {% pdf {{ site.data.cv.dlink }} %}

site.data.cv.dlink is: https://raw.githubusercontent.com/hosseinabdinf/curriculum-vitae/main/hosseinabdi.pdf

also, I tested it with the embed tag: <embed src="{{ site.data.cv.dlink }}" width="500" height="375">

the problem still remains and the result is the same!

But when I use local PDF file, it works fine and the PDF shows correctly: local: /assets/hosseinabdi.pdf {% pdf {{ site.data.cv.local }} %}

I think the type of link we use is the cause of this problem, so if we use a direct link there will be no problem anymore.