Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDF is downloaded instead of displayed #6

Open
jlconlin opened this issue Oct 18, 2021 · 10 comments
Open

PDF is downloaded instead of displayed #6

jlconlin opened this issue Oct 18, 2021 · 10 comments
Labels
bug Something isn't working

Comments

@jlconlin
Copy link

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
Copy link
Owner

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
Copy link
Author

@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
Copy link
Owner

@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
Copy link
Author

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
Copy link
Owner

MihajloNesic commented Oct 23, 2021

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
Copy link

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
Copy link
Owner

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 MihajloNesic added the bug Something isn't working label Dec 31, 2021
@akbaritabar
Copy link

akbaritabar commented Dec 31, 2021

@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
Copy link
Author

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
Copy link

hosseinabdinf commented Jul 15, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants