Are you keen on enhancing your Blogger posts by adding PDF files? Integrating PDFs into your blog can be valuable if you wish to share documents, reports, or guides with your audience. Thankfully, Blogger makes it a breeze to upload and share PDFs alongside your written content. This guide will walk you through the simple steps to publish PDFs in your Blogger posts.
Before you commence, ensure you have the PDF file ready for uploading. This could be a document you've created yourself or one you've obtained from another source. Make certain the content is refined and relevant to your blog post's topic.
To effortlessly embed PDFs into your Blogger post, you'll need to host the file online. Google Drive provides a convenient solution for this. Follow these steps to upload your PDF to Google Drive:
Once your PDF is uploaded to Google Drive, you must generate a shareable link. Here's how:
PDF is ready now we have added this to the blogger post.
Copy below CSS code and paste it into your theme custom CSS. (Follow the Youtube Video)
.pdf-wrapper {
display: flex;
align-items: center;
justify-content: center;
}
.pdf-container {
position: relative;
width: 600px;
aspect-ratio: 1/1.399;
}
.pdf-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.download-wrapper {
text-align: center;
margin: 30px 0;
}
.pdfdownload-btn {
padding: 8px 15px;
border-radius: 50px;
background-color: blue;
color: white;
border: none;
outline: none;
cursor: pointer;
}
Now that you have the shareable link, you can embed the PDF into your Blogger post. Follow these steps:
Make sure you replace the pdf google drive link with your link.
<div class="pdf-wrapper">
<div class="pdf-container">
<iframe
class="pdf-viewer"
src="YOUR_PDF_LINK_HERE"
frameborder="0"
></iframe>
</div>
</div>
<div class="download-wrapper">
<button class="pdfdownload-btn">Download</button>
</div>
Copy below code and paste it at the bottom of your post.
<script>
const downloadBtns = document.querySelectorAll(".pdfdownload-btn");
downloadBtns.forEach(function (btn, index) {
btn.addEventListener("click", function () {
const pdfViewer = document.querySelectorAll(".pdf-viewer")[index];
const pdfSrc = pdfViewer.src;
const fileId = pdfSrc.match(/\/file\/d\/(.+)\/preview/)[1];
const downloadUrl = `https://drive.google.com/uc?export=download&id=${fileId}`;
window.open(downloadUrl, "_blank");
});
});
</script>
Before publishing your post, it's wise to preview it to ensure everything looks as intended. Click on the "Preview" button to see how the PDF is displayed within your post. Once you're satisfied, you can publish your post for your audience to see.
Incorporating PDFs into your Blogger posts can enrich your content and provide valuable resources for your readers. By following these simple steps, you can easily upload and share PDF files alongside your written content. Whether you're sharing documents, reports, or guides, integrating PDFs into your Blogger posts is a straightforward process that can elevate your blogging experience. Give it a try and witness how it enhances your blogging journey!