简体   繁体   中英

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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