Embed PDF file into a page or post - PaperMod theme

I need to embed a PDF file into a page or post.
I found this resource: GitHub - anvithks/hugo-embed-pdf-shortcode: A shortcode for Hugo(https://gohugo.io/) which allows you to embed a PDF file in a page using Pdf.js (https://mozilla.github.io/pdf.js/)
I tried it, following the instructions, but it didn’t work for me.
Is there anyone experienced with that resource or others to embed a PDF file into pages or posts?

1 Like

Based on open issues (including your own) and pull requests, it appears that anvithks/hugo-embed-pdf-shortcode is not actively maintained.

You are encountering this issue.

To fix, change the first line of the shortcode to:

<script src= '/js/pdf-js/build/pdf.js'></script>
1 Like

Thank you very much @jmooring
I much appreciate your reply!
Thank you very much again.

I’ve found the Adobe PDF Embed API to be the best solution for my needs. You can see it in action here for example (source here).

Thanks @jmooring for helping out here. I haven’t been able to update the plugin in the last few months.
I have some time now and I will be looking at the issues and some updates to the shortcode with some more features.

@nicfab If you are still facing issues please reach out on Github and i will help you out to get it working.

Thank you @anvithks
The solution proposed by @jmooring works fine.
Now the plugin works properly.
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?

1 Like

Please take this discussion to https://github.com/anvithks/hugo-embed-pdf-shortcode.

1 Like

Thank you @alcarazr

I understand that your solution is:
<script src="[https://documentcloud.adobe.com/view-sdk/main.js"></script>](https://documentcloud.adobe.com/view-sdk/main.js%22%3E%3C/script%3E) <script type="text/javascript"> document.addEventListener("adobe_dc_view_sdk.ready", function(){ var adobeDCView = new AdobeDC.View({clientId: "5b6be996ab824b0e8113830d11740fa3", divId: "adobe-dc-view"}); adobeDCView.previewFile({ content:{location: {url: "https://fisiquimicamente.com/recursos-fisica-quimica/oposiciones/fisica/cantabria-2016-e1/cantabria-2016-E1.pdf"}}, metaData:{fileName: "cantabria-2016-E1.pdf"} }, {embedMode: "IN_LINE"}); }); </script>

Do you use the script each time, embedding it in the post/page, or have you created a Shortcode?

1 Like

Ok. Sure!

Do you use the script each time, embedding it in the post/page, or have you created a Shortcode?

I haven’t created a shortcode yet but I’ll explore it. Thanks!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.