Skip to content

Releases: PNW-Computers/SelfPublishing-Convert-Verify-Scripts

Version 1.0

27 Feb 17:58
7694c58

Choose a tag to compare

Amazon-KDP-PDFConverter v1.0 — Initial Release

A Python build script that compiles a multi-part Markdown book into a KDP-compliant paperback PDF using Pandoc + XeLaTeX.


What's included

  • build_book_template.py — the build script
  • README.md — setup, configuration reference, and troubleshooting guide

Features

  • Auto-discovery of chapter .md files across part folders with natural sort ordering
  • Markdown preprocessing pipeline (runs before Pandoc):
    • YAML frontmatter stripping
    • Decorative --- line removal (prevents Pandoc's "narrow column" longtable bug)
    • HTML <img> → Markdown image conversion
    • Image path normalization (URL-decode + ../ stripping for repo-root-relative resolution)
    • Zero-width space removal (KDP non-printable markup flag)
    • Internal .md cross-link → bold text conversion
    • Chapter/Appendix heading normalization to H1
    • Code block hard-wrapping at 75 chars (pre-Pandoc overflow prevention)
  • KDP safety features injected via LaTeX header:
    • Image width capped at 80% of text width
    • Image height capped at 35% of text height (prevents caption + float overflow past bottom margin)
    • FloatBarrier at every subsection (no figure drift across sections)
    • fancyhdr headers with book title (even pages) and chapter title (odd pages)
    • URL hyphenation via xurl
    • geometry loaded once via Pandoc -V flags only (no double-load conflict)
  • Configurable at the top of the script — page size, margins, fonts, metadata, and folder structure require no changes outside the config block

Requirements

  • Python 3.8+
  • Pandoc
  • XeLaTeX (MiKTeX / TeX Live / MacTeX)
  • System fonts matching MAIN_FONT, SANS_FONT, MONO_FONT (defaults: Cambria, Calibri, Consolas)

Default output format

  • Trim size: 8.5 × 11 in (US Letter)
  • Margins: inner 1in / outer 0.75in / top 1in / bottom 0.75in
  • DPI: 300
  • Easily reconfigured for other KDP trim sizes (A4, 6×9, etc.) by editing the geometry variables

Notes

This is a template — all personal metadata has been removed. Edit the config block at the top of the script before use. See README.md for full setup instructions.