Add options paperSize and margin for pdf

This commit is contained in:
Samy Pessé
2014-06-02 17:57:47 +02:00
parent 5f207f5e14
commit a91245d575
2 changed files with 31 additions and 10 deletions
+14 -1
View File
@@ -107,7 +107,20 @@ Here are the options that can be stored in this file:
"toc": true,
// Font size for the fiel content
"fontSize": 12
"fontSize": 12,
// Paper size for the pdf
// Choices are [u’a0’, u’a1’, u’a2’, u’a3’, u’a4’, u’a5’, u’a6’, u’b0’, u’b1’, u’b2’, u’b3’, u’b4’, u’b5’, u’b6’, u’legal’, u’letter’]
"paperSize": "a4",
// Margin (in pts)
// Note: 72 pts equals 1 inch
"margin": {
"right": 62,
"left": 62,
"top": 36,
"bottom": 36
}
}
}
```
+17 -9
View File
@@ -30,10 +30,6 @@ Generator.prototype.finish = function() {
.then(function() {
var d = Q.defer();
var format = that.options.extension || path.extname(that.options.output);
var pdfOptions = _.defaults(that.options.pdf || {}, {
"fontSize": 12,
"toc": true
});
if (!that.options.cover && fs.existsSync(path.join(that.options.output, "cover.jpg"))) {
that.options.cover = path.join(that.options.output, "cover.jpg");
@@ -50,14 +46,26 @@ Generator.prototype.finish = function() {
};
if (format == "pdf") {
var pdfOptions = _.defaults(that.options.pdf || {}, {
"fontSize": 12,
"toc": true,
"paperSize": "a4",
"margin": {
"right": 62,
"left": 62,
"top": 36,
"bottom": 36
}
});
_.extend(_options, {
"--margin-left": "62",
"--margin-right": "62",
"--margin-top": "36",
"--margin-bottom": "36",
"--margin-left": String(pdfOptions.margin.left),
"--margin-right": String(pdfOptions.margin.right),
"--margin-top": String(pdfOptions.margin.top),
"--margin-bottom": String(pdfOptions.margin.bottom),
"--pdf-add-toc": Boolean(pdfOptions.toc),
"--pdf-default-font-size": String(pdfOptions.fontSize),
"--paper-size": "a4",
"--paper-size": String(pdfOptions.paperSize),
});
}