Accepted answer

There is a Fork with a fix for that. You can set the dpi now with this fork:

You need to compile it for your OS and then you can set the dpi with page.dpi

console.log('Loading a web page');
var page = require('webpage').create();
var url = '';, function (status) {
   //Page is loaded!
   page.dpi=300; // this is where you actually set the DPI

Be sure you use the same OS for phatomjs on where you compile it, because the compile process reads the dpi from the system and uses it for phantomjs. This means: If you compile it on windows with standard dpi 96 and use it on centos you will have a scale of 96/72 because centos uses 72 dpi


Yes, >2.0 has a poorly defined A4. I scale my html by adjusting the css style from within rasterize.js just before the .render command.

page.evaluate(function () {
    var the_page = document.getElementsByTagName("page")[0];'0 0';'0 0';'scale(1.28)'; ='scale(1.28)';

Related Query

More Query from same tag