Yes you heard it right, you can now download locked PDFs from google drive using simple Javascript code with following steps below. Make sure you follow it thoroughly.
Open any Browser ( Recommended : Mozilla firefox )
Paste the url (eg : https://drive.google.com/file/d/1n7
XqZ6TXQsDIPcJP1qKMne8BeYVgw0Fx/view?pli=1) and open the file.
Right Click or Use shortcut keys Ctrl + Shift + K (according to the browser) to inspect the elements. You can see there's another tab on right "console". Click it
Paste the 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("BCA_fifthsemester.pdf"); }; jspdf.src = 'https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.5.3/jspdf.debug.js'; document.body.appendChild(jspdf);
In case, if you see these warning like Don't paste code in console. Type " allow pasting " to bypass the rules.
Now run the code. Enjoy ๐
ย