Craft Language Reference

The Craft Language is an XML-based markup language for defining Docraft documents. Each XML tag maps to a visual element that the library parses, layouts, and renders to PDF.

Write declarative, readable document templates without touching low-level drawing APIs.

Core Elements

🏗️ Document Structure

The foundation — <Document>, <Header>, <Body>, <Footer> sections and how they compose pages automatically.

Document Structure
📝 Text

Styled text with fonts, sizes, colors, alignment, bold, italic, underline, and justified text support.

Text

Visual Elements

🔷 Shapes

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

Shapes
🖼️ Images

Embed PNG and JPEG images from files, or inject raw pixel data at runtime via the template engine (including base64).

Images
📈 Charts

Scatter, spline, line, histogram, and pie charts, drawn directly on the page from <Series model="..."> JSON data.

Charts

Complex Structures

📊 Tables

Grid-based tables with column titles, cell backgrounds, and automatic JSON data binding via <Foreach>.

Tables
📋 Lists

Ordered and unordered lists — number, roman numeral, dash, star, circle, and box markers.

Lists
📐 Layout

Nested <Layout> containers with horizontal/vertical orientation and weighted child distribution for multi-column designs.

Layout
🔄 Templating

Data binding with ${variables}, <Foreach> loops, and JSON model integration for dynamic documents.

Templating

Configuration

⚙️ Settings

Page format (A3, A4, A5, Letter, Legal), orientation (portrait/landscape), custom fonts, and section height ratios.

Settings
📄 Metadata

Document properties — title, author, creator, producer, subject, and keywords.

Document Metadata