mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-25 03:42:30 +00:00
Add options paperSize and margin for pdf
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -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),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user