X Tutup
Skip to content

PDF margin settings don't seem to work #221

@yhor1e

Description

@yhor1e

Summary

I set the PDF setting in book.json. But they're not reflected in book.pdf.

  • HonKit version: 3.6.20
  • ebook-convert: calibre 3.48.0

I guess "--margin-left", "--margin-right", "--margin-top", "--margin-bottom" options don't work correctly.
https://github.com/honkit/honkit/blob/v3.6.20/packages/honkit/src/output/ebook/getConvertOptions.ts#L59-L62

Step to reproduce

  1. Run npx honkit init
  2. Create book.json and set PDF margin settings like this in it
{
    "pdf": {
        "margin": {
            "top": 0,
            "right": 0,
            "bottom": 0,
            "left": 0
        }
    }
}

ref: https://honkit.netlify.app/config.html#pdf-options

  1. Run npx honkit pdf.
  2. Then, book.pdf has margins.

screenshot

  • Link to code example:

https://github.com/yhor1e/honkit-pdf-margin-settings-dont-work

Expected results

PDF margin settings work.

Actual results

PDF margin settings don't work.

Actual Log
$ npx honkit pdf --log=debug
debug: readme found at README.md 
debug: summary file found at SUMMARY.md 
debug: cleanup folder "/var/folders/vn/535j39x133gdtz48y1__4hkm0000gn/T/tmp-12216qAT7P46Ds7UB" 
info: 5 plugins are installed 
info: 5 explicitly listed 
info: plugin "highlight" is loaded
info: plugin "search" is loaded
info: plugin "lunr" is loaded
info: plugin "fontsettings" is loaded
info: plugin "theme-default" is loaded
info: found 2 pages 
info: found 5 asset files 
debug: calling hook "config" 
debug: calling hook "init" 
debug: copy assets from theme /Users/yhorie/work/honkit-pdf-margin-settings-dont-work/node_modules/@honkit/honkit-plugin-theme-default/_assets/ebook 
debug: copy resources from plugin /Users/yhorie/work/honkit-pdf-margin-settings-dont-work/node_modules/@honkit/honkit-plugin-highlight/css 
debug: copy asset ".gitignore" 
debug: copy asset "book.pdf" 
debug: copy asset "package-lock.json" 
debug: copy asset "package.json" 
debug: copy asset "screenshot.png" 
debug: calling hook "page:before" 
debug: calling hook "page:before" 
debug: calling hook "page" 
debug: calling hook "page" 
debug: calling hook "finish:before" 
debug: Conversion options changed from defaults:
  pdf_page_numbers: True
  book_producer: u'HonKit'
  breadth_first: True
  level2_toc: u"descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter-2 ')]"
  margin_top: 0.0
debug:   pdf_header_template: u'\n<!DOCTYPE HTML>\n<html lang style="font-family: sans-serif; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%;">\n    <head>\n        <meta charset="UTF-8">\n        <title>_SECTION_</title>\n        <meta http-equiv="X-UA-Compatible" content="IE=edge">\n        <meta name="description" content>\n        <meta name="generator" content="HonKit 3.6.20">\n        \n        \n        \n    \n    \n        \n        <style>\na:focus {\n  outline: thin dotted;\n}\na:active,\na:hover {\n  outline: 0;\n}\nbutton::-moz-focus-inner,\ninput::-moz-focus-inner {\n  border: 0;\n  padding: 0;\n}\n.link-inherit {\n  color: inherit;\n}\n.link-inherit:focus,\n.link-inherit:hover {\n  color: inherit;\n}\n.page .section a:active,\n.page .section a:focus,\n.page .section a:hover {\n  outline: 0;\n  text-decoration: underline;\n}\n</style>\n        \n    \n\n    \n            \n        \n\n    \n\n    \n        \n    \n        \n    \n        \n    \n        \n    \n        \n    \n        \n    \n\n        \n    </head>\n    <body style="margin: 0; font-family: sans-serif; color: #000; text-size-adjust: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;">\n        \n<div class="pdf-header" style="margin-top: 20px; padding-bottom: 10px; border-bottom: 1px solid #eee; color: #aaa;">\n    <span>_SECTION_</span>\n</div>\n\n        \n    </body>\n</html>\n\n'
  page_breaks_before: u'/'
  paper_size: u'a4'
  max_levels: 1.0
  chapter: u"descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter ')]"
  margin_left: 0.0
  margin_bottom: 0.0
  pdf_default_font_size: 12.0
  level1_toc: u"descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter-1 ')]"
  pdf_footer_template: u'\n<!DOCTYPE HTML>\n<html lang style="font-family: sans-serif; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%;">\n    <head>\n        <meta charset="UTF-8">\n        <title>_SECTION_</title>\n        <meta http-equiv="X-UA-Compatible" content="IE=edge">\n        <meta name="description" content>\n        <meta name="generator" content="HonKit 3.6.20">\n        \n        \n        \n    \n    \n        \n        <style>\na:focus {\n  outline: thin dotted;\n}\na:active,\na:hover {\n  outline: 0;\n}\nbutton::-moz-focus-inner,\ninput::-moz-focus-inner {\n  border: 0;\n  padding: 0;\n}\n.link-inherit {\n  color: inherit;\n}\n.link-inherit:focus,\n.link-inherit:hover {\n  color: inherit;\n}\n.page .section a:active,\n.page .section a:focus,\n.page .section a:hover {\n  outline: 0;\n  text-decoration: underline;\n}\n</style>\n        \n    \n\n    \n            \n        \n\n    \n\n    \n        \n    \n        \n    \n        \n    \n        \n    \n        \n    \n        \n    \n\n        \n    </head>\n    <body style="margin: 0; font-family: sans-serif; color: #000; text-size-adjust: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;">\n        \n<div class="pdf-footer" style="margin-top: 20px; padding-top: 10px; border-top: 1px solid #eee; color: #aaa;">\n    <span></span>\n    <span class="footer-pages-count" style="float: right;">_PAGENUM_</span>\n</div>\n\n        \n    </body>\n</html>\n\n'
  no_chapters_in_toc: True
  pdf_sans_family: u'Arial'
  margin_right: 0.0
  level3_toc: u"descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter-3 ')]"
  publisher: u'HonKit'
  pdf_mono_font_size: 12.0
debug: 1% Converting input to HTML...
InputFormatPlugin: HTML Input running
on /var/folders/vn/535j39x133gdtz48y1__4hkm0000gn/T/tmp-12216qAT7P46Ds7UB/SUMMARY.html
debug: Language not specified
Creator not specified
debug: Building file list...
debug: Normalizing filename cases
debug: Rewriting HTML links
debug: 34% Running transforms on e-book...
debug: Merging user specified metadata...
debug: Detecting structure...
debug: 	Detected chapter: Introduction
debug: 	Detected chapter: Reproduction
debug: Auto generated TOC with 2 entries.
debug: Flattening CSS and remapping font sizes...
debug: Source base font size is 12.00000pt
debug: Removing fake margins...
debug: Cleaning up manifest...
Trimming unused files from manifest...
debug: Creating PDF Output...
67% Running PDF Output plugin
debug: Splitting markup on page breaks and flow limits, if any...
debug: 78% Rendered SUMMARY.html
debug: 89% Rendered index.html
debug: 100% Rendered reproduction.html
debug: Rendered PDF in 0.476303 seconds:
debug: PDF output written to /var/folders/vn/535j39x133gdtz48y1__4hkm0000gn/T/tmp-12216qAT7P46Ds7UB/index.pdf
debug: Output saved to   /var/folders/vn/535j39x133gdtz48y1__4hkm0000gn/T/tmp-12216qAT7P46Ds7UB/index.pdf
debug: calling hook "finish" 
info: >> generation finished with success in 3.5s ! 
info: >> 1 file(s) generated 
debug: cleaning up... OK 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup