Sharing PDFs on your WordPress website is an effective way to provide resources, reports and other valuable documents to your visitors. However, managing large files can sometimes slow down your site if not done properly. One of the best methods to embed a PDF in WordPress is by using Google Drive. This approach offers a scalable solution that ensures your PDFs are easily viewable, responsive, and optimized for mobile users.
Why this process is the best?
Before we get into the technical steps, let’s take a moment to understand the benefits of embedding PDFs from Google Drive into your WordPress website:
- Scalability: Google Drive handles large files efficiently without consuming your server bandwidth, keeping your website’s performance intact.
- Responsive Design: PDFs embedded from Google Drive are automatically responsive, ensuring they look great on desktops, tablets, and mobile devices.
- No Plugins Required: Embedding PDFs directly from Google Drive doesn’t require installing additional plugins, making the process straightforward and plugin-free.
How to Embed a PDF in WordPress
In this article, I ‘ll show you how to upload a PDF to Google Drive, make it publicly accessible and embed it in WordPress so it’s viewable directly in the browser which will offload the server utilization to google servers while the pdf still ll be publicly viewable.
Step 1: Upload the PDF
First, you need to upload your PDF file to Google Drive. This method works for any document you want to make publicly available on your WordPress site, but PDFs are particularly useful for this purpose.
- Go to Google Drive: Open your browser and navigate to Google Drive.
- Sign In: If you’re not already logged into your Google account, you will be prompted to sign in.
- Upload the PDF: On the Google Drive home page, click the New button on the left side of the screen. Select File Upload from the dropdown menu. Browse your computer, select the PDF file you want to upload, and hit Open. The upload will begin immediately.
- Wait for the Upload to Complete: Once the PDF is uploaded, it will appear in your Google Drive.
Step 2: Make the PDF Public
Now that your PDF is uploaded, you need to make it publicly accessible to anyone visiting your WordPress site. Here’s how:
- Right-Click on the PDF: In Google Drive, right-click on the PDF file and select Get link.
- Change Link Settings: By default, the file will be set to Restricted, which means only people you share it with directly can view it. To make the PDF accessible to everyone, click on the dropdown next to Restricted and select Anyone with the link.
- Set Permissions to Viewer: Ensure that the file permissions are set to Viewer so that anyone with the link can view the PDF without making any changes.
- Copy the Link: Click on Copy link to grab the public URL of the PDF.
Step 3: Modify the Link for Seamless Viewing
The link you copied will open the PDF in Google Drive’s default viewer, but to embed it smoothly in WordPress, you’ll need to modify the link slightly.
- Locate the Original Link: The copied link will look something like this:
https://drive.google.com/file/d/1IP6c2lLwJcAiyDmUpL1K8JusqLs8u0JC/view
- Change the URL: Replace the view part of the URL with preview. The updated URL should look like this:
https://drive.google.com/file/d/1IP6c2lLwJcAiyDmUpL1K8JusqLs8u0JC/preview
Step 4: Embed the PDF in WordPress
Now that the PDF link is ready, it’s time to embed the PDF into your WordPress page or post. Just add a button or an anchor link and add the final URL.
Check the implementation
To check the implementation, Click here to view the PDF publicly
Embedding a PDF in WordPress using Google Drive is an efficient and scalable solution that ensures your documents are viewable across devices while keeping your website fast and responsive. By following these simple steps—uploading your PDF, making it public, modifying the URL for preview mode, and embedding it via an iframe—you can offer a seamless document viewing experience to your visitors.
Also read: All Good Web Development Articles Are Here
This method eliminates the need for additional plugins, reduces the risk of performance issues, and ensures your PDFs are easily accessible to all users. Whether you’re sharing reports, eBooks, or other documents, Google Drive is the perfect tool for embedding PDFs in WordPress.