简体   繁体   English

Nodejs | npm:html-pdf,设置pdf页面的高度

[英]Nodejs | npm : html-pdf,set height of the pdf page

My code 我的密码

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');
                });

This is always renders the page with a constant height. 这总是以恒定的高度呈现页面。 How to set the page height ? 如何设置页面高度? Thanks ! 谢谢 !

You have to give Header and footer "height" in the options . 您必须在选项中给页眉和页脚“高度”。 This will something like: 这将类似于:

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');
                });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM