javascript - Phantomjs renders wrong snapshot size -


we try make snapshot different webpages using phantomjs (both resizable , fixed pages). when try on wikipedia (page resizable), viewport dimensions client ignored. problem in render, define viewport width , height. seems phantomjs first stretches page (snapshot has bit bigger text original wikipedia), crops right margin, , adds large margin in bottom.

here code:

var owebpage = webpage.create();  owebpage.viewportsize = {     width  : nviewportwidth,     height : nviewportheight };  owebpage.onloadfinished = function() {     if (owebpage.injectjs('inject.js')) {         // nothing being done affect page size in inject.js         try {             owebpage.evaluate(function() {                 // nothing being done affect page size here either             });             owebpage.render(simagepath, {format: 'png', quality: '100'});             phantom.exit();         } catch (oerror) {             phantom.exit(1);         }     } else {         phantom.exit(1);     } };  owebpage.open(smyurl, function(sstatus) {     if (sstatus != 'success') {         phantom.exit(1);     } }); 

we tried document size , window size within evaluate() code, both equal viewport size comes client.

we tried play page.zoomfactor, didn't help. cliprect doesn't help, cuts page, it's resized on snapshot.

on other pages tried works perfect, , on wikipedia behaviour strange. weird. have had such issues?

found out problem on wikipedia page in css. contained properties 'vw' value, treated phantom incorrectly. not pixel value, percentage viewport. workaround parse css , rid of 'vw' properties.

though, after done phantom stopped work. switched nightmarejs - @ least stable.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -