Module pdf

Module pdf 

Source
Expand description

PDF generation module for markdown-to-pdf conversion.

This module handles the complete process of converting parsed markdown content into professionally formatted PDF documents. It provides robust support for generating PDFs with proper typography, layout, and styling while maintaining the semantic structure of the original markdown.

The PDF generation process preserves the hierarchical document structure through careful handling of block-level and inline elements. Block elements like headings, paragraphs, lists and code blocks are rendered with appropriate spacing and indentation. Inline formatting such as emphasis, links and inline code maintain proper nesting and style inheritance.

The styling system offers extensive customization options through a flexible configuration model. This includes control over: fonts, text sizes, colors, margins, spacing, and special styling for different content types. The module automatically handles font loading, page layout, and proper rendering of all markdown elements while respecting the configured styles.

Error handling is built in throughout the generation process to provide meaningful feedback if issues occur during PDF creation. The module is designed to be both robust for production use and flexible enough to accommodate various document structures and styling needs.

Structs§

Pdf
The main PDF document generator that orchestrates the conversion process from markdown to PDF. This struct serves as the central coordinator for document generation, managing the overall structure, styling application, and proper sequencing of content elements. It stores the input markdown tokens that will be processed into PDF content, along with style configuration that controls the visual appearance and layout of the generated document. The generator maintains two separate font families - a main text font used for regular document content and a specialized monospace font specifically for code sections. These fonts are loaded based on the style configuration and stored internally for use during the PDF generation process.

Constants§

CURRENT_CODE_FONT_OVERRIDE 🔒
Thread-local storage for the current code font override during rendering This allows passing the code font through the rendering call stack without major structural changes.