这个分支允许设置 dpi https://github.com/martonw/phantomjs/tree/issue-%2313553
然后您可以使用 page.dpi = 72
来设置 dpi
console.log('Loading a web page');
var page = require('webpage').create();
var url = 'http://phantomjs.org/';
page.open(url, function (status) {
//Page is loaded!
page.dpi=300; // this is where you actually set the DPI
page.render("test.pdf");
phantom.exit();
});
render()
呢?顺便说一下,他们要求300 DPI,因为它是用于打印的项目。 - Thomas Jones