-
-
Notifications
You must be signed in to change notification settings - Fork 533
Open
Description
Whether I try the html-pdf command or render the page from within the API, any elements I specify with a dimension end up being bigger than they should be. Essentially if I define a div to be the same dimensions of the page it still ends up being 30% bigger than the page.
The HTML, intending to fit within a single page of US letter size:
<html>
<head>
<title>test case</title>
</head>
<body style="background-color: yellow">
<div style="width: 21cm; height: 27cm; border: solid 1px black;">This should be within page bounds!?</div>
</body>
</html>
The JS I was using:
var fs = require('fs');
var pdf = require('html-pdf');
var options = {
// Export options
"directory": "/tmp", // The directory the file gets written into if not using .toFile(filename, callback). default: '/tmp'
"width": "216mm", // allowed units: mm, cm, in, px
"height": "279mm", // allowed units: mm, cm, in, px
// File options
"type": "pdf", // allowed file types: png, jpeg, pdf
"quality": "100", // only used for types png & jpeg
// Script options
"phantomPath": "./node_modules/phantomjs-prebuilt/bin/phantomjs"
};
var html = fs.readFileSync('./tests/document.html', 'utf8');
pdf.create(html, options).toFile('./out.pdf', function(err, res) {
if (err) {
return console.log(err);
}
console.log(res);
});
Using node-html-pdf version 2.1.0, MacOS X 10.12, NodeJS 6.7.0
andreleon
Metadata
Metadata
Assignees
Labels
No labels
