11 Jul 2024

How to Download Protected PDF from Google Drive?

 You can still download the PDF protected with the sharing settings of Google Drive by following these simple instructions:


Method 1. How to Download Protected PDF from Google Drive

Open the protected PDF in Google Drive and take a scrolling screenshot of it using a Chrome extension or any screenshot tool like GoFullPage and export the screenshot in PDF format.

Method 2. How to Download Restricted PDF from Google Drive?


Instructions: Head to your web browser and access Google Drive to access the restricted PDF. Double-click the PDF file to open it and press the "Ctrl + Shift + C" keys on the keyboard while using Windows. Then, hit the "Console" tab next to the "Elements." Afterward, paste the given code into the "Console" and hit the "Enter" key on the keyboard. This will download your PDF file automatically.


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];
if (!/^blob:/.test(img.src)) {
continue ;
}
let canvasElement = document.createElement( 'canvas' );
let con = canvasElement.getContext( "2d" );
canvasElement.width = img.width;
canvasElement.height = img.height;
con.drawImage(img, 0, 0,img.width, img.height);
let imgData = canvasElement.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.3.2/jspdf.min.js' ;
document.body.appendChild(jspdf);

For Landscape PDF Code

let jspdf = document.createElement("script");
jspdf.onload = function () {
    let pdf = new jsPDF({ orientation: 'landscape' });
    let elements = document.getElementsByTagName("img");
    for (let i = 0; i < elements.length; i++) {
        let img = elements[i];
        if (!/^blob:/.test(img.src)) {
            continue;
        }
        let canvasElement = document.createElement('canvas');
        let con = canvasElement.getContext("2d");
        canvasElement.width = img.width;
        canvasElement.height = img.height;
        con.drawImage(img, 0, 0, img.width, img.height);
        let imgData = canvasElement.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.3.2/jspdf.min.js';
document.body.appendChild(jspdf);

No comments:

Post a Comment