Document Structure
A Craft Language file is an XML document whose root element is <Document>.
Inside the root you define three optional sections — Header, Body, and
Footer — that map to the top, middle, and bottom areas of every page.
Minimal Example
<Document>
<Body margin_left="20" margin_right="20">
<Text font_size="24" style="bold">Hello, Docraft!</Text>
</Body>
</Document>
Root Element: <Document>
<Document> carries no attributes of its own — the output path is not
part of the .craft file at all; it’s passed separately, either as the
second CLI argument (docraft_tool in.craft out.pdf) or to
DocraftLoomPdfCreator::render(path) from C++ (see
Getting Started). Its recognized children are
<Header>/<Body>/<Footer> (<Body> required),
<Settings> (Settings), and <Metadata> (Document Metadata); any
other direct child is silently ignored.
Sections
Common Node Attributes
Every content node supports these attributes:
Attribute |
Type |
Description |
|---|---|---|
|
string |
Logical name for DOM lookups. |
|
float |
Position in points (used with |
|
float |
Explicit size in points. Only applied to node types that declare a
setter for it (e.g. |
|
float |
Inner padding in points, between a container’s own box and its
children (default |
|
float |
Uniform outer spacing in points, reserved by the parent stack around
this node. Adjacent margins collapse via |
|
float |
Proportional sizing share. Only meaningful for a direct child of a
horizontal |
|
|
Positioning mode (default |
|
int |
Paint order only (higher paints later/on top); does not affect layout. |
|
bool |
When |
Note
auto_fill_width/auto_fill_height and a path attribute on
<Document> are recognized as XML tokens by the parser but are not
currently read anywhere — they have no effect on the rendered document.
Color Values
Colors can be specified as:
Hex:
#RRGGBBor#RRGGBBAANamed:
black,white,red,green,blue,yellow,magenta,cyan,purpleTemplate:
${variable}or${data("field")}
Page Break
Insert <NewPage/> to force a manual page break.
<Body>
<Text>Page one content</Text>
<NewPage/>
<Text>Page two content</Text>
</Body>
Blank Line
Insert <Blank/> to add vertical spacing.
<Text>First paragraph</Text>
<Blank/>
<Text>Second paragraph</Text>