API Reference

Complete C++ API documentation for Docraft — auto-generated from source code comments. Explore the library’s modules below to understand how to build, layout, and render PDF documents.

Core Components

📄 Document

The main entry point — DocraftDocument owns the document tree, metadata, and drives the entire rendering pipeline.

Document
🎯 Context

Runtime context and cursor management — tracks the current rendering position, page boundaries, and layout state.

Document Context

Document Model

🧱 Core Nodes

Base classes for all document elements — DocraftNode, DocraftText, DocraftImage, and structural components like Header, Body, Footer.

Model — Core Nodes
🔷 Shapes

Geometric primitives — Rectangle, Circle, Triangle, Line, Polygon with fill, stroke, and border styling.

Model — Shapes
📦 Containers

Layout containers — DocraftLayout (horizontal/vertical), DocraftTable, DocraftList (ordered/unordered) for composing complex structures.

Model — Content Containers
🏷️ Types & Enums

Common types, enums, and data structures — TextStyle, TextAlignment, PageFormat, Orientation, and more.

Model — Types & Enums

Rendering Pipeline

📐 Layout Engine

Flow-based layout system with automatic page breaking — calculates positions and sizes for all document nodes before rendering.

Layout Engine
🎨 Renderer

The rendering coordinator — traverses the document tree and delegates drawing operations to specialized painters.

Renderer
🖌️ Painters

Specialized painters for each element type — TextPainter, ShapePainter, ImagePainter, TablePainter, etc.

Painters
🔌 Backend

Abstracted PDF backend interface — currently implemented with libharu but designed to be pluggable.

Rendering Backend

Template & Parsing

📝 Craft Parser

XML parser for the Craft Language — converts .craft files into a document object model using pugixml.

Craft Language Parser
🔄 Templating Engine

Data binding and template expansion — ${variables}, <Foreach> loops, conditional rendering, and JSON model integration.

Templating

Utilities

🛠️ Utilities

Helper functions for color parsing, string manipulation, font management, base64 decoding, and file operations.

Utilities