How to Download Protected PDF from Google Drive?

Do you want to download protected PDF files from Google Drive? If your answer is YES then don’t look further as we have got you covered.

Google Drive is a very popular service provided by Google. You must be using Google Drive to store your photos, videos, documents, and files.

Google Drive service is also used by website owners to store their data. If you use Google Drive then you must know that Google allows you to disable the downloading option.

If someone wants to download your PDF file from Google Drive, they would not get a download option.

What would you do if you are not getting a download option in Google Drive? There is a secret method that can be used to download the protected PDF file from Google Drive.

If you are struggling to download the protected PDF files from Google Drive then look no further because this post has got you covered.

Without any further ado, let’s get started:

Downloading Protected PDF From Google Drive

Downloading protected PDF files from Google Drive is not so easy because google stores PDF files in separate images as a Blob.

If someone requests to download the PDF file, Google compiles all images together and presents you with a PDF to download.

You can download the viewed-only pdf files from Google Drive by using the methods given below.

Method 1: Use JS Codes

In this method, we are going to use JS Codes that allow you to download the protected or view-only PDF files from Google Drive.

JavaScript Code
let jspdf = document.createElement(“script”);
jspdf.onload = function () {
let pdf = new jsPDF();
let elements = document.getElementsByTagName(“img”);
for (let i in elements) {
let img = elements[i];
console.log(“add img “, img);
if (!/^blob:/.test(img.src)) {
console.log(“invalid src”);
continue;
}
let can = document.createElement(‘canvas’);
let con = can.getContext(“2d”);
can.width = img.width;
can.height = img.height;
con.drawImage(img, 0, 0, img.width, img.height);
let imgData = can.toDataURL(“image/jpeg”, 1.0);
pdf.addImage(imgData, ‘JPEG’, 0, 0);
pdf.addPage();
}
pdf.save(“download.pdf”);
};
jspdf.src = ‘https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.5.3/jspdf.debug.js’;
document.body.appendChild(jspdf);

Here are a few simple steps to use this JS Code to download the protected PDF files.

  • If you are trying to download a file from the Chrome browser, open the PDF file.
  • Now scroll down and come to the last page of the PDF.
  • Next, you have to open a Developer Console. To open it press the Ctrl + Shift + C for Windows or Cmd + Shift + C for Mac.
  • Choose a console option from the Developers Console as shown in the figure.
  • Now copy the above-mentioned JS Code and paste it into the Console, and hit the Enter button.
  • When you do so, the PDF file will start downloading.
  • That’s it.

Method 2: Use Chrome Extension

In this method, we are going to use a Chrome Extension instead of any code.

This Chrome extension Captures a complete PDF File on the Website as a Screenshot and then downloads the screengrab as a PDF.

Here’s how to download a protected PDF file using a Chrome extension:

  • First, you have to add GoFullPage Extension in chrome.
  • For that search GoFullPage on your chrome extension and click on Add Button as shown in the image below.
  • Once you successfully added the extension, open the Restricted PDF File.
  • Now click on the GoFullPage Extension icon at the top right corner.
  • The extension will auto-scroll the webpage to capture everything on the screen as a screenshot.
  • It will take time depending on the length of the PDF.
  • Once the process is completed, you can Download the screenshot as a PDF document.
  • That’s it.

Method 3: Use Script.js code

In this method, you have to download a Zip file by clicking here.

⦁ First, you have to extract the Zip file.
⦁ Once extracted, open the script “Method_1_Script.js” and copy all the JS Code.
⦁ Now open the Restricted PDF and open the Developers Console as shown in method 1.
⦁ Now paste JS Code in Console and hit the Enter button.
⦁ After a few seconds, the browser will prompt you to save the PDF file.
⦁ That’s it, save the file and enjoy.

We hope this article helped you in downloading restricted or view-only PDF files from Google Drive.

Leave a Comment