【问题标题】:Nodejs | npm : html-pdf,set height of the pdf page节点 | npm : html-pdf,设置pdf页面的高度
【发布时间】:2018-02-17 02:17:59
【问题描述】:

我的代码

var options = {format:'A3',border:{top:'30px',bottom:'30px',left:'10px'}}
                pdf.create(html,options).toBuffer(function(err, buffer){
                    res.type('application/pdf');
                    res.end(buffer, 'binary');
                });

这总是以恒定的高度呈现页面。 如何设置页面高度? 谢谢!

【问题讨论】:

标签: html node.js pdf npm


【解决方案1】:

您必须在选项中指定页眉和页脚“高度”。 这将类似于:

var options = {format:'A3',header: {  "height": "5mm"},footer: { "height": "5mm"}, border:{top:'30px',bottom:'30px',left:'10px'}}
                pdf.create(html,options).toBuffer(function(err, buffer){
                    res.type('application/pdf');
                    res.end(buffer, 'binary');
                });

【讨论】:

  • 这将如何帮助设置整个页面的高度?我想设置页面的高度(页眉、正文、页脚)这并不能解决我的问题。
  • 您可以使用诸如“height”之类的页面选项:“10.5in”,//允许的单位:mm、cm、in、px “width”:“8in”,来自npmjs.com/package/html-pdf#options
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-08-11
  • 2016-02-14
  • 1970-01-01
  • 1970-01-01
  • 2021-11-14
  • 2020-09-19
  • 2020-04-16
相关资源
最近更新 更多