download non downloadable pdf google drive

Solutions on MaxInterview for download non downloadable pdf google drive by the best coders in the world

showing results for - "download non downloadable pdf google drive"
Sergio
17 Apr 2016
1let jspdf = document.createElement("script");
2 
3jspdf.onload = function () {
4 
5    let pdf = new jsPDF();
6    let elements = document.getElementsByTagName("img");
7    for (let i in elements) {
8        let img = elements[i];
9        console.log("add img ", img);
10        if (!/^blob:/.test(img.src)) {
11            console.log("invalid src");
12            continue;
13        }
14        let can = document.createElement('canvas');
15        let con = can.getContext("2d");
16        can.width = img.width;
17        can.height = img.height;
18        con.drawImage(img, 0, 0, img.width, img.height);
19        let imgData = can.toDataURL("image/jpeg", 1.0);
20        pdf.addImage(imgData, 'JPEG', 0, 0);
21        pdf.addPage();
22    }
23 
24    pdf.save("download.pdf");
25};
26 
27jspdf.src = 'https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.5.3/jspdf.debug.js';
28document.body.appendChild(jspdf);
29