Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDF margin settings don't seem to work #221

Closed
yhor1e opened this issue Sep 15, 2021 · 0 comments · Fixed by #224
Closed

PDF margin settings don't seem to work #221

yhor1e opened this issue Sep 15, 2021 · 0 comments · Fixed by #224
Labels
Type: Bug Bug or Bug fixes

Comments

@yhor1e
Copy link
Contributor

yhor1e commented Sep 15, 2021

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 
@yhor1e yhor1e changed the title PDF margin settings seem to not work PDF margin settings don't seem to work Sep 15, 2021
yhor1e added a commit to yhor1e/honkit that referenced this issue Sep 15, 2021
The ebook-covert options `--margin-left`, `--margin-right`, `--margin-top`, `--margin-bottom` don't work. So change them to  `--pdf-page-margin-left`, `--pdf-page-margin-right`, `--pdf-page-margin-top`, `--pdf-page-margin-bottom`.

Ref. honkit#221
@azu azu added the Type: Bug Bug or Bug fixes label Sep 16, 2021
@azu azu closed this as completed in 7ffa130 Sep 16, 2021
@azu azu mentioned this issue Sep 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Bug or Bug fixes
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants