Orchestrator

DocraftLoomPdfCreator is the top-level entry point of the loom pipeline (see About Docraft) — it owns the header/footer/body node tree, drives Measure → Layout → Pagination via create(), and Rendering + file output via render(). It is built for you by DocraftLoomCraftLanguageParser::edit_creator() when parsing a .craft file (see Craft Language Parser); see Getting Started for end-to-end usage.

class DocraftLoomPdfCreator

Orchestrates the full loom pipeline (Measure -> Layout -> Pagination -> Rendering) over an optional header/footer plus a body root, producing a multi-page PDF.

Header and footer are plain loom nodes (e.g. a VStack), not a dedicated node type — they are laid out once, stamped to render on every page, and re-visited by the rendering pass for each physical page. The body is laid out as one continuous flow and then split across pages by DocraftLoomPaginationProcessor.

Public Functions

explicit DocraftLoomPdfCreator(std::shared_ptr<interfaces::DocraftLoomIVisitorNode> root_node)
~DocraftLoomPdfCreator() = default
void set_header(std::shared_ptr<nodes::DocraftLoomNode> header)

Sets the header content, laid out once and re-drawn on every page.

void set_footer(std::shared_ptr<nodes::DocraftLoomNode> footer)

Sets the footer content, laid out once and re-drawn on every page.

void set_section_ratios(float header_ratio, float body_ratio, float footer_ratio)

Sets the fraction of the page height given to header/body/footer.

Defaults to legacy’s 0.06/0.88/0.06. Values are not required to sum to 1.0F, but the body’s own height is always page_height - header_height - footer_height so it never overlaps the other two regions.

float header_ratio() const

Returns the header’s fraction of page height (see set_section_ratios()).

float body_ratio() const

Returns the body’s fraction of page height (see set_section_ratios()).

float footer_ratio() const

Returns the footer’s fraction of page height (see set_section_ratios()).

void set_page_format(docraft::backend::DocraftPageSize size, docraft::backend::DocraftPageOrientation orientation)

Sets the page size/orientation.

Applies immediately to the backend, so it must be called before create() &#8212; create() reads the backend’s page_width()/ page_height() to compute section heights.

void register_font(const std::string &family_name, const std::optional<std::string> &normal_path, const std::optional<std::string> &bold_path = std::nullopt, const std::optional<std::string> &italic_path = std::nullopt, const std::optional<std::string> &bold_italic_path = std::nullopt)

Registers a font family from TTF file(s), so font_name="family_name" (or "family_name-Bold"/"-Italic"/"-BoldItalic") can be used by DocraftLoomText.

Each provided variant is loaded via the backend and aliased in DocraftFontRegistry under family_name plus the matching suffix; a variant left as std::nullopt is simply not registered (resolving that style falls back to the closest available variant, or the requested name itself &#8212; see DocraftFontResolver::resolve()).

Throws:

docraft::exception::BackendStateException – if a provided font file fails to load.

void set_metadata(const DocraftDocumentMetadata &metadata)

Applies document info-dict metadata (title/author/etc.) to the backend.

Applies immediately; a later call overwrites what was set before.

void set_header_margins(const Margins &margins)

Sets the header’s margins, inset from the header region’s own edges.

void set_body_margins(const Margins &margins)

Sets the body’s margins.

The body’s paginated flow starts margin.top below the header and its per-page usable height shrinks by margin.top + margin.bottom; margin.left/right inset every top-level child.

Sets the footer’s margins, inset from the footer region’s own edges.

void create()
void render(const std::filesystem::path &output_path)
const std::shared_ptr<interfaces::DocraftLoomIVisitorNode> &root_node() const

Returns the body root node passed to the constructor (test/inspection accessor &#8212; mirrors DocraftLoomNode::edit_layout_box()’s non-const-getter convention).

const std::shared_ptr<nodes::DocraftLoomNode> &header() const

Returns the header node, or nullptr if none was set.

const std::shared_ptr<nodes::DocraftLoomNode> &footer() const

Returns the footer node, or nullptr if none was set.

const Margins &header_margins() const
const Margins &body_margins() const
const Margins &footer_margins() const
struct Margins

Margins (points) inset from a section’s (header/body/footer) own edges.

Public Members

float top = kDefaultMarginPt
float bottom = kDefaultMarginPt
float left = kDefaultMarginPt
float right = kDefaultMarginPt

Public Static Attributes

static constexpr float kDefaultMarginPt = 20.0F

Default per-edge margin (points) applied when a section (or the <Header>/<Body>/<Footer> element parsed from craft language) doesn’t override it via an explicit margin_top/margin_bottom/margin_left/ margin_right attribute &#8212; keeps content from sitting flush against its region’s own edge.