Generate pdf by JavaScript in chrome console

Viewed 116

I want to download a PDF embedded in a webpage. So what I did is write a program to programmatically download all pages. But I what I want is as I can download all pages so can I make a PDF canvas and programmatically add those pages and finally download the PDF?

My code is:

res = [];
c = 0;
function setinter(){
    var images = document.images;
    for( i = 0; i < images.length;i++){
        if (images[i].className == 'left'){
            if(res.includes(images[i].src)){
                continue;
            }
            res.push(images[i].src);
            l = document.createElement('a');
            l.download = images[i].src;
            l.href = images[i].src;
            l.click();
            c = c + 1;
        }
    }
    btn = document.getElementById('next_slide');
    btn.click();
    //console.log(c);
    if (c == 205 ){ 
        clearInterval(r);
    }
}
var r = setInterval(setinter,700);
0 Answers
Related