# Embed PDF file into a page or post - PaperMod theme

**URL:** <https://discourse.gohugo.io/t/embed-pdf-file-into-a-page-or-post-papermod-theme/36440>\
**Category:** support\
**Created:** [January 8, 2022, 12:26pm UTC](https://discourse.gohugo.io/t/embed-pdf-file-into-a-page-or-post-papermod-theme/36440 "2022-01-08T12:26:58Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![nicfab](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/nicfab/32/15818_2.png) [@nicfab](https://discourse.gohugo.io/u/nicfab)\
**Post date:** [January 8, 2022, 12:26pm UTC](https://discourse.gohugo.io/t/embed-pdf-file-into-a-page-or-post-papermod-theme/36440/1 "2022-01-08T12:26:58Z")

</div>

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/)](https://github.com/anvithks/hugo-embed-pdf-shortcode)  
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?

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [January 8, 2022, 7:39pm UTC](https://discourse.gohugo.io/t/embed-pdf-file-into-a-page-or-post-papermod-theme/36440/2 "2022-01-08T19:39:31Z")

</div>

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

You are encountering this [issue](https://github.com/anvithks/hugo-embed-pdf-shortcode/issues/18).

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

```auto
<script src= '/js/pdf-js/build/pdf.js'></script>

```

---

<div class="post-metadata">

**Author:** ![nicfab](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/nicfab/32/15818_2.png) [@nicfab](https://discourse.gohugo.io/u/nicfab)\
**Post date:** [January 8, 2022, 8:11pm UTC](https://discourse.gohugo.io/t/embed-pdf-file-into-a-page-or-post-papermod-theme/36440/3 "2022-01-08T20:11:47Z")

</div>

> [@jmooring](#):
>
> To fix, change the first line of the shortcode to:
> 
> ```auto
> <script src= '/js/pdf-js/build/pdf.js'></script>
> 
> ```

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

---

<div class="post-metadata">

**Author:** ![alcarazr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/alcarazr/32/11576_2.png) [@alcarazr](https://discourse.gohugo.io/u/alcarazr)\
**Post date:** [January 8, 2022, 10:18pm UTC](https://discourse.gohugo.io/t/embed-pdf-file-into-a-page-or-post-papermod-theme/36440/4 "2022-01-08T22:18:10Z")

</div>

I’ve found the [Adobe PDF Embed API](https://www.adobe.io/apis/documentcloud/dcsdk/pdf-embed.html) to be the best solution for my needs. You can see it in action [here](https://fisiquimicamente.com/recursos-fisica-quimica/oposiciones/fisica/cantabria-2016-E1/) for example (source [here](https://github.com/rodrigoalcarazdelaosa/fisiquimicamente/blob/main/content/es/oposiciones-fisica-ejercicios/cantabria-2016-E1/index.md)).

---

<div class="post-metadata">

**Author:** ![anvithks](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/anvithks/32/12284_2.png) [@anvithks](https://discourse.gohugo.io/u/anvithks)\
**Post date:** [January 9, 2022, 3:38am UTC](https://discourse.gohugo.io/t/embed-pdf-file-into-a-page-or-post-papermod-theme/36440/5 "2022-01-09T03:38:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![nicfab](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/nicfab/32/15818_2.png) [@nicfab](https://discourse.gohugo.io/u/nicfab)\
**Post date:** [January 9, 2022, 5:50am UTC](https://discourse.gohugo.io/t/embed-pdf-file-into-a-page-or-post-papermod-theme/36440/6 "2022-01-09T05:50:15Z")

</div>

> [@anvithks](#):
>
> @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?

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [January 9, 2022, 5:51am UTC](https://discourse.gohugo.io/t/embed-pdf-file-into-a-page-or-post-papermod-theme/36440/7 "2022-01-09T05:51:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nicfab](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/nicfab/32/15818_2.png) [@nicfab](https://discourse.gohugo.io/u/nicfab)\
**Post date:** [January 9, 2022, 5:55am UTC](https://discourse.gohugo.io/t/embed-pdf-file-into-a-page-or-post-papermod-theme/36440/8 "2022-01-09T05:55:24Z")

</div>

> [@alcarazr](#):
>
> I’ve found the [Adobe PDF Embed API](https://www.adobe.io/apis/documentcloud/dcsdk/pdf-embed.html) to be the best solution for my needs. You can see it in action [here](https://fisiquimicamente.com/recursos-fisica-quimica/oposiciones/fisica/cantabria-2016-E1/) for example (source [here](https://github.com/rodrigoalcarazdelaosa/fisiquimicamente/blob/main/content/es/oposiciones-fisica-ejercicios/cantabria-2016-E1/index.md)).

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?

---

<div class="post-metadata">

**Author:** ![nicfab](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/nicfab/32/15818_2.png) [@nicfab](https://discourse.gohugo.io/u/nicfab)\
**Post date:** [January 9, 2022, 5:56am UTC](https://discourse.gohugo.io/t/embed-pdf-file-into-a-page-or-post-papermod-theme/36440/9 "2022-01-09T05:56:00Z")

</div>

> [@jmooring](#):
>
> Please take this discussion to [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/)](https://github.com/anvithks/hugo-embed-pdf-shortcode).

Ok. Sure!

---

<div class="post-metadata">

**Author:** ![alcarazr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/alcarazr/32/11576_2.png) [@alcarazr](https://discourse.gohugo.io/u/alcarazr)\
**Post date:** [January 9, 2022, 8:53am UTC](https://discourse.gohugo.io/t/embed-pdf-file-into-a-page-or-post-papermod-theme/36440/10 "2022-01-09T08:53:18Z")

</div>

> 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!

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [January 11, 2022, 8:54am UTC](https://discourse.gohugo.io/t/embed-pdf-file-into-a-page-or-post-papermod-theme/36440/11 "2022-01-11T08:54:10Z")

</div>

Closed on January 11, 2022, 8:54am UTC

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