M
M
monochromer2016-11-08 15:51:27
Node.js
monochromer, 2016-11-08 15:51:27

How to remove extra padding above and below for headers and footers when generating pdf with html-pdf in nodejs?

Test script:

var fs = require('fs');
var pdf = require('html-pdf');

var srcFile = 'test.html';
var html = fs.readFileSync(srcFile, 'utf8');

var options = {
  "type": "pdf",
  "orientation": "portrait",
  "format": "A4",
  "margin": "0",
  "border": {
    "top":    "0cm",
    "right":  "0cm",
    "bottom": "0cm",
    "left":   "0cm"
  }
};

var data = pdf.create(html, options);

data.toFile('./index.pdf', function(err, res) {
  if (err) return console.log(err);
  console.log(res);
});

The top margins are visible in the picture:
85b4b2c332f145edbef1c9f0abcee76e.png
html-pdf package
https://github.com/marcbachmann/node-html-pdf

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question