# Embedding PDFs into Blog Post?

**URL:** https://forum.ghost.org/t/embedding-pdfs-into-blog-post/28104
**Category:** Using Ghost
**Created:** [January 24, 2022, 10:26pm UTC](https://forum.ghost.org/t/embedding-pdfs-into-blog-post/28104 "2022-01-24T22:26:16Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![JorCor1](https://avatars.discourse-cdn.com/v4/letter/j/54ee81/32.png) [@JorCor1](https://forum.ghost.org/u/JorCor1)
#### Post date: [January 24, 2022, 10:26pm UTC](https://forum.ghost.org/t/embedding-pdfs-into-blog-post/28104/1 "2022-01-24T22:26:16Z")

</div>

I’m trying to post some PDFs on my blog, but I’d like for them to be viewable without the need to download them.

My plan was to upload to GoogleDrive/Dropbox, set them to shareable with link, and then use HTML code to embed them, but I’ve tried this already and it’s not working.  
Is there another way?

Thank you!

---

<div class="post-metadata">

### Author: ![rajeshtaylor](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/rajeshtaylor/32/16716_2.png) [@rajeshtaylor](https://forum.ghost.org/u/rajeshtaylor)
#### Post date: [January 25, 2022, 2:07pm UTC](https://forum.ghost.org/t/embedding-pdfs-into-blog-post/28104/2 "2022-01-25T14:07:27Z")

</div>

The only instance I’ve seen recently is a blog using [Scribd](https://www.scribd.com/) and then pasting the html code into a post. It is a paid service however. I’m using the /file option for pdf’s under 5MB and leaving a download link for larger files.

---

<div class="post-metadata">

### Author: ![Marky-Gee](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/marky-gee/32/3289_2.png) [@Marky-Gee](https://forum.ghost.org/u/Marky-Gee)
#### Post date: [January 26, 2022, 10:34am UTC](https://forum.ghost.org/t/embedding-pdfs-into-blog-post/28104/3 "2022-01-26T10:34:17Z")

</div>

I was able to get it working with uploading to GoogleDrive, then have a custom theme for any pages where I’m embedding the PDF. I just paste the link to PDF into the post (making sure it’s the link ending in /view). The script will replace the link with an iframe embedding the post and then add a link to download the file below it

The template is just the same as the normal post template, but with this script added to it. You might even be able to add this directly to the code injection, but I’m not sure.

```auto
 <div class="post-body">
        <div class="post-inner js-post-content">
            {{content}}
            <script>
                $('.js-post-content').find('a').each(function () {
                    console.log($(this).attr('href'));
                    var div = document.createElement("div")
                    var frame = document.createElement("iframe");
                    div.setAttribute('style', "text-align:center")
                    frame.setAttribute('src', $(this).attr('href').replace("/view", "") + "/preview");
                    frame.style.width = "100%";
                    frame.onload = function () {
                        frame.style.height = (document.body.scrollHeight * 0.7) + "px";
                    };
                    var anchor = document.createElement("a");
                    anchor.setAttribute('href', $(this).attr('href').replace("/view", "").replace("file/d/", "uc?export=download&id="));
                    anchor.innerText = "Download Document"
                    div.appendChild(frame);
                    div.appendChild(anchor)
                    this.parentNode.replaceChild(div, this);
                });
            </script>
        </div>
    </div>

```

I intend to do something similar with the new file upload cards and use google’s doc viewer to remove the need to upload to google.

```auto
<iframe src="https://docs.google.com/viewer?url={{URL OF THE PDF UPLOADED TO GHOST}}&embedded=true" style="width:100%; height:500px;" frameborder="0"></iframe>

```

---

<div class="post-metadata">

### Author: ![Spont](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/spont/32/16129_2.png) [@Spont](https://forum.ghost.org/u/Spont)
#### Post date: [February 20, 2022, 3:12pm UTC](https://forum.ghost.org/t/embedding-pdfs-into-blog-post/28104/4 "2022-02-20T15:12:05Z")

</div>

Still don’t understand why we can’t embed pdfs like this into ghost with the embed function. I’m not a coder, but this is extremely frustrating. Embedding documents should not be so challenging. Has anyone developed a workaround that does not involved editing a theme?
