Is Google Drive View-Only PDF really protected from being copied?

Of course, nothing can escape Snipping Tool screenshot.

But what about the shortest way to convert to a pdf document file? Because Google Drive somehow, giving the ability to restrict viewers from downloading if the owner so chooses, convert the pdf into some partly encoded html format such that the printing will be blank.

The solution I've seen so far is from this site. Using JavaScript, we can play with rendering picture/text.

Basically injecting a JS code (ctrl+shift+c) in console, which I will paste below. After hitting Enter and closing the console window, the Save As dialog box shows up and the pdf file saved is not bad.

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

This is another solution: https://github.com/zeltox/Google-Drive-PDF-Downloader

And another, but very similar with the above two:

This entry was posted in Technical. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.