I've been building a tool that generates AI-powered analysis reports in markdown (github.com/ansari-project/ragdiff - not a plug, just context). Getting high-quality, readable PDFs turned out way harder than expected.
The problem:
Markdown is underspecified, so tools have to make guesses. Most solutions produce mediocre output or are painful to work with:
- Pandoc: Powerful but requires deep LaTeX knowledge to get good results. Template debugging is arcane, and the LaTeX intermediate step adds surprising complexity.
- npm packages: Most produce poor typography, awkward page breaks, and inconsistent spacing.
- wkhtmltopdf and similar: Limited styling control, quirky rendering behavior.
What I actually need: proper margins, good fonts, readable code blocks, sensible page breaks, high quality diagrams from things like mermaid etc.
My current solution:
Markdown → HTML (with CSS) → Headless Chrome → PDF
But this feels like reinventing the wheel.
Is there a better way in 2025? What do you use for programmatic markdown → PDF when quality actually matters? Am I missing an obvious tool, or is "Chrome as PDF engine" actually the pragmatic solution?
robthebrew•1h ago