我试图将标题添加到使用node-webshot生成的PDF中,但没有显示出来。将标题添加到Node生成的PDF Webshot
我使用这个代码:
webshot('https://www.google.com', 'google.pdf', options, function (err) {
if(err) throw err;
console.log('Saved to PDF');
});
随着选项对象是这样的:
var options = {
"paperSize": {
"format": "A4",
"orientation": "portrait",
"border": "0.25cm",
"header": {
"height": "2cm",
"contents": function() {
return phantom.callback(function(pageNum, numPages) {
return '<h1>' + pageNum + '/' + numPages + '</h1>';
});
}
}
}
};
我试着做内容的功能它是如何表现的PhantomJS documentation但它不工作,因为幻像没有定义。我找不到任何如何使用webshot添加页眉/页脚的例子。
PDF生成正确,但标题为空,没有写入任何内容。
我该如何解决这个问题?
我的回答有帮助吗?有什么问题吗?你可以[接受](http://meta.stackexchange.com/a/5235)一个答案,如果它解决了你的问题(只是你知道)。 –