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

Provide option to allow users to download the PDF file #27

Closed
anvithks opened this issue Jan 10, 2022 · 12 comments · Fixed by #35
Closed

Provide option to allow users to download the PDF file #27

anvithks opened this issue Jan 10, 2022 · 12 comments · Fixed by #35

Comments

@anvithks
Copy link
Owner

anvithks commented Jan 10, 2022

What?
Provide a option to allow the user to download the PDF file.

Why?
Sometimes I need to publish PDF in “secure mode” (I mean that people don’t have to can downloading the PDF); other times, I need to publish PDF allowing people to download.
Currently, I seem that it isn’t possible to download the PDF; am I wrong?

Originally posted by @nicfab in #26 (comment)

@nicfab
Copy link

nicfab commented Jan 10, 2022

What? Provide a option to allow the user to download the PDF file.

Why? Sometimes I need to publish PDF in “secure mode” (I mean that people don’t have to can downloading the PDF); other times, I need to publish PDF allowing people to download. Currently, I seem that it isn’t possible to download the PDF; am I wrong?

Originally posted by @nicfab in #26 (comment)

Thank you.
I will much appreciate your effort to develop a solution.

@RoneoOrg
Copy link
Contributor

Hi there,

Currently, I seem that it isn’t possible to download the PDF; am I wrong?

The author of this blog, @SuryaThiru seemed to find the solution, maybe you want to have a look to the code?

Please take the time to report here if you find a solution, and I may submit a PR

@nicfab
Copy link

nicfab commented Jul 31, 2022

Hi there,

Currently, I seem that it isn’t possible to download the PDF; am I wrong?

The author of this blog, @SuryaThiru seemed to find the solution, maybe you want to have a look to the code?

Please take the time to report here if you find a solution, and I may submit a PR

I tried, but it didn't work for me.

@RoneoOrg
Copy link
Contributor

I'm having a look right now. The relevant commit is here: SuryaThiru/portfolio@dc1d16b

Note that the PDF url is hardcoded, I would like to avoid that. I'll report here if I find a way

@nicfab
Copy link

nicfab commented Jul 31, 2022

I'm having a look right now. The relevant commit is here: SuryaThiru/portfolio@dc1d16b

Note that the PDF url is hardcoded, I would like to avoid that. I'll report here if I find a way

Thank you.
Firstly, indeed, the PDF URL is hardcoded into the layouts/shortcodes/embed-pdf.html and so I should modify it each time.
Secondly, I need to embed more than one PDF file on a page, and I seem that the solution doesn't allow what I need.

@RoneoOrg
Copy link
Contributor

Firstly, indeed, the PDF URL is hardcoded into the layouts/shortcodes/embed-pdf.html

This should be fixed with a {{ .Get "url" }} at the right place, I'll give a try in the next days

@RoneoOrg
Copy link
Contributor

RoneoOrg commented Jul 31, 2022

Firstly, indeed, the PDF URL is hardcoded into the layouts/shortcodes/embed-pdf.html

This should be fixed with a {{ .Get "url" }} at the right place, I'll give a try in the next days

Solved with replacing the line 63 with

    <a href="{{ .Get "url" }}" download>

This update is included in this fork: https://github.com/RoneoOrg/hugo-shortcode-roneo-embed-pdf

I will use it to check if everything works fine, and will push a PR. Please feel free to ping me in a month if I do not provide this PR

@nicfab
Copy link

nicfab commented Jul 31, 2022

Firstly, indeed, the PDF URL is hardcoded into the layouts/shortcodes/embed-pdf.html

This should be fixed with a {{ .Get "url" }} at the right place, I'll give a try in the next days

Solved with replacing the line 63 with

    <a href="{{ .Get "url" }}" download>

This update is included in this fork: https://github.com/RoneoOrg/hugo-shortcode-roneo-embed-pdf

I will use it to check if everything works fine, and will push a PR. Please feel free to ping me in a month if I do not provide this PR

I understand that it is sufficient to put the following folders locally:

  1. layouts/shortcodes/embed-pdf.html;
  2. static/js/pdf-js

Is it so? Is the only files and folders to add locally?

@RoneoOrg
Copy link
Contributor

Is the only files and folders to add locally?

Yes that's it. I personally use Hugo's Theme Component, it's a little bit harder to set up but easier to update

@anvithks
Copy link
Owner Author

anvithks commented Aug 1, 2022

Thank you so much @RoneoOrg and @nicfab .
I will try to spend some time with this and merge the PR.

Haven't been able to spend enough time on this due to my day job.

@nicfab
Copy link

nicfab commented Aug 1, 2022

@RoneoOrg I tried as you said but, unfortunately, it didn't work.
I will wait for some further intervention by you and @anvithks
Thanks a lot.

@RoneoOrg
Copy link
Contributor

RoneoOrg commented Sep 2, 2022

@RoneoOrg I tried as #27 (comment) but, unfortunately, it didn't work.

More info could be useful to help debugging

RoneoOrg added a commit to RoneoOrg/hugo-embed-pdf-shortcode-roneo that referenced this issue Sep 30, 2022
@RoneoOrg RoneoOrg mentioned this issue Sep 30, 2022
2 tasks
anvithks added a commit that referenced this issue Mar 17, 2023
* fix URL and load pdf.js

* git cherry-pick bc6286d:  Add a download button. Reference: #27

* Download button: improve CSS

* Download button: Do not depend on Font-awesome and replace with a SVG

* Download button: Improve a11y: add aria-label

* Download button: Improve CSS + SVG

* Retained only download button code

---------

Co-authored-by: Anvith KS <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants