hugo-embed-pdf-shortcode icon indicating copy to clipboard operation
hugo-embed-pdf-shortcode copied to clipboard

Provide option to allow users to download the PDF file

Open anvithks opened this issue 2 years ago • 12 comments

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 https://github.com/anvithks/hugo-embed-pdf-shortcode/issues/26#issuecomment-1008236117

anvithks avatar Jan 10 '22 17:01 anvithks

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.

nicfab avatar Jan 10 '22 17:01 nicfab

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?

  • blog: https://suryathiru.github.io/cv
  • source code: https://github.com/SuryaThiru/portfolio

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

RoneoOrg avatar Jul 31 '22 04:07 RoneoOrg

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?

  • blog: https://suryathiru.github.io/cv
  • source code: https://github.com/SuryaThiru/portfolio

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.

nicfab avatar Jul 31 '22 07:07 nicfab

I'm having a look right now. The relevant commit is here: https://github.com/SuryaThiru/portfolio/commit/dc1d16be49b0420df6127321e3370be1ba6be455

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

RoneoOrg avatar Jul 31 '22 07:07 RoneoOrg

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.

nicfab avatar Jul 31 '22 07:07 nicfab

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 avatar Jul 31 '22 08:07 RoneoOrg

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

RoneoOrg avatar Jul 31 '22 09:07 RoneoOrg

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?

nicfab avatar Jul 31 '22 09:07 nicfab

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

RoneoOrg avatar Jul 31 '22 16:07 RoneoOrg

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.

anvithks avatar Aug 01 '22 13:08 anvithks

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

nicfab avatar Aug 01 '22 14:08 nicfab

@RoneoOrg I tried as https://github.com/anvithks/hugo-embed-pdf-shortcode/issues/27#issuecomment-1200388792 but, unfortunately, it didn't work.

More info could be useful to help debugging

RoneoOrg avatar Sep 02 '22 19:09 RoneoOrg