wch / webshot

Take screenshots of web pages from R
http://wch.github.io/webshot/
228 stars 40 forks source link

setting higher resolution with casper #83

Open stevepowell99 opened 5 years ago

stevepowell99 commented 5 years ago

I'm using webshot to export high-resolution images from visNetwork but struggling to improve the resolution beyond FHD. I've tried this:

webshot::webshot("export.html", file = "p.png", vwidth = 1980, zoom=1,  eval = '
    casper.then(function () {
            window.screen = {
                width: 4096,
                height: 2304
            };
        });

;')

... but nothing seems to make any difference (not even setting zoom = 2). The best I can do is just:

webshot::webshot("export.html", file = "p1hix.png", vwidth = 1920,zoom=1)
The best result I can get is, I think, at the resolution of my actual browser. The export.html file seems fine, there is nothing restricting the width of the canvas. Is there any way I can set webshot to simulate a higher resolution screen?

wch commented 5 years ago

You might want to try out webshot2. You'd do something like:

webshot2::webshot("export.html", vwidth = 4096, vheight = 2304)

https://github.com/rstudio/webshot2