jekyll-pdf-embed icon indicating copy to clipboard operation
jekyll-pdf-embed copied to clipboard

PDF is downloaded instead of displayed

Open jlconlin opened this issue 3 years ago • 10 comments

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?

jlconlin avatar Oct 18 '21 13:10 jlconlin

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/

MihajloNesic avatar Oct 20 '21 18:10 MihajloNesic

@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.

jlconlin avatar Oct 21 '21 15:10 jlconlin

@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 :)

MihajloNesic avatar Oct 21 '21 20:10 MihajloNesic

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.

jlconlin avatar Oct 22 '21 02:10 jlconlin

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

MihajloNesic avatar Oct 23 '21 09:10 MihajloNesic

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

akbaritabar avatar Dec 24 '21 21:12 akbaritabar

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.

MihajloNesic avatar Dec 31 '21 09:12 MihajloNesic

@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.

akbaritabar avatar Dec 31 '21 10:12 akbaritabar

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.

jlconlin avatar May 17 '22 14:05 jlconlin

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.

hosseinabdinf avatar Jul 15 '22 16:07 hosseinabdinf