MarkdownPrint converts Markdown into polished, Apple-native PDFs.
No WebKit, no HTML renderer, no web view. The PDF pipeline is direct CoreText, CoreGraphics, and PDFKit, with an optional SwiftUI preview wrapper.
Open Examples/demo.pdf. That file was generated from this library's own user manual -- table of contents, code blocks with syntax highlighting, tables, links, typography, headings, the works.
Or generate one yourself in 30 seconds:
swift run markdownprint-cli README.md README.pdf --tocimport MarkdownPrint
let engine = MarkdownPrintEngine()
let result = try engine.render(markdown, options: .init(
theme: .dark,
withTOC: true
))
try result.pdfData.write(to: URL(fileURLWithPath: "output.pdf"))That's the blessed path. render() returns a PDFRenderResult with .pdfData, .pageCount, and .diagnostics. Everything else is optional.
MarkdownPrint converts Markdown into polished Apple-native PDFs with tables, code, math, images, themes, TOC, links, cancellation, progress, and SwiftUI support.
A4, light theme, San Francisco typography, clickable links, page numbers, metadata. No config required. Just markdown in, PDF out.
When you need more: dark mode, high contrast, Dynamic Type scaling, custom themes (JSON or programmatic), watermarks, headers/footers, line numbers, text justification, cross-references, footnotes, hyphenation, native LaTeX math, async rendering with cancellation and progress.
.package(url: "https://github.com/Alektronnik/MarkdownPrint", from: "1.0.0")| Target | Lines |
|---|---|
CLIParser |
99.4% |
PDFRenderer |
90.1% |
MarkdownPrintCore (Swift) |
99.0% |
| Overall (all sources) | 89.0% |
| Overall (SwiftUI excluded) | 94.4% |
569 tests, 0 failures. Coverage run completes cleanly; test execution is ~4.3s after build.
MarkdownPrint+SwiftUI.swift is excluded from the unit-test threshold -- SwiftUI views are tested via UI/integration tests, not XCTest assertions.
Known limitation: PDF/UA tagged structure is not yet implemented. PDFs render as Tagged: no. This is documented in the CHANGELOG and planned for a future release. The drawing pipeline (CoreGraphics via CGPDFContext) does not expose tagging APIs; tagged PDF requires post-processing the generated PDF byte stream.
- User Manual -- full API reference, Markdown support, themes, CLI flags
- Architecture -- C++17 core, Swift bridge, CoreGraphics renderer
- DocC -- Getting Started, Architecture, SwiftUI Integration
swift run markdownprint-cli input.md [output.pdf] [--toc] [--theme dark] [--watermark DRAFT] ...15 flags. --help shows everything.
MIT.