diff options
author | Samy Pessé <samypesse@gmail.com> | 2014-06-02 17:57:47 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2014-06-02 17:57:47 +0200 |
commit | a91245d575a26bb3172b4bf453f8f6b2cbc187d2 (patch) | |
tree | f0108cfeb9a2ddd1e13f2c798b7f2453a7091e13 | |
parent | 5f207f5e146d1e1cdcb8aa1e2545323e10a906bd (diff) | |
download | gitbook-a91245d575a26bb3172b4bf453f8f6b2cbc187d2.zip gitbook-a91245d575a26bb3172b4bf453f8f6b2cbc187d2.tar.gz gitbook-a91245d575a26bb3172b4bf453f8f6b2cbc187d2.tar.bz2 |
Add options paperSize and margin for pdf
-rw-r--r-- | README.md | 15 | ||||
-rw-r--r-- | lib/generate/ebook/index.js | 26 |
2 files changed, 31 insertions, 10 deletions
@@ -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 + } } } ``` diff --git a/lib/generate/ebook/index.js b/lib/generate/ebook/index.js index 0cde1a9..51afaeb 100644 --- a/lib/generate/ebook/index.js +++ b/lib/generate/ebook/index.js @@ -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), }); } |