javascript - convert HTML elements to images (server side) -


i'd convert dynamic html elements images (jpg, png, ..) , don't want screenshot of webpage nor static html file.

the purpose on server-side:

var imgs=[] (var = 0; < templates.length; i++){      var temphtml = $(templates[i]).find("#imageplaceholder").attr("src", url[i]);      imgs.push(convert2image(temphtml)); }  

you can use headless browser phantomjs , phantomjs bridge in order integrate application. bridge between node , phantomjs.(https://www.npmjs.com/package/phridge)

var webpage = require('webpage'); var page = webpage.create();  page.viewportsize = {   width: 1920,   height: 1080 };  page.open('http://youwebsite/yourpage', function (status) {   var base64 = page.renderbase64('png');   phantom.exit();   console.log(base64); }); 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -