Steps to Download Restricted Google Drive PDF

Steps to Download Restricted Google Drive PDF

Simple medthod

Here are the simple steps to download view-only protected PDF from Google Drive using Chrome browser:

Step 1

Open the PDF file on your Chrome Browser. Let the file load completely and scroll to the bottom of the page. Steps to download restricted Google Drive PDF

Step 2

Now open Developer Console by pressing Ctrl+ Shift + C (F12) for Windows or Cmd + Shift + C for Mac. Then click on Console tab. Steps to download restricted Google Drive PDF

Step 3

Now paste the this script in the Developer Console and hit Enter.

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);

Steps to download restricted Google Drive PDF

Step 4

When everything has done, the PDF file will be downloaded. Steps to download restricted Google Drive PDF

Advanced medthod

The simple JS method works for simple PDF files, but if you wish to download large PDF files with complex orientation in high quality, then the simple JS code may not work that great, here you can try this advanced trick to save the download protected Google Drive PDF.

Step 1

Download Google Drive PDF Downloader file and extract the content. Open Method_1_Script.js. Then copy the script into Developer Console and press Enter. Steps to download restricted Google Drive PDF

Step 2

After few seconds the browser will prompt you to save a file with extension *.PDF_DataFile". Save this file and copy it into the Input directory which is inside the folder you downloaded earlier. Steps to download restricted Google Drive PDF Steps to download restricted Google Drive PDF

Step 3

If you are using Windows then navigate to Windows folder and double click on GeneratePDF.cmd. If you are using Linux then navigate to Linux folder and execute GeneratePDF. Steps to download restricted Google Drive PDF

Step 4

A successful message will be shown once the whole process completes. Navigate to the Output folder and enjoy.

💡

You can use Method_2_Script.js only for PDF with less than 20 pages, if you experience any errors or slow down then follow Method_1_Script.js

Resources

  1. https://bytesbin.com/download-view-only-pdf-google-drive
  2. https://github.com/zeltox/Google-Drive-PDF-Downloader