Model — Types & Enums
Value types, enumerations, and small structs used throughout the model layer.
DocraftColor
Color helper supporting named colors, RGB components, hex codes, and template expressions.
-
class DocraftColor
Color helper that supports named, RGB, and hex representations.
Public Functions
-
explicit DocraftColor(ColorName name = ColorName::kBlack)
Creates a color from a known name.
- Parameters:
name – Named color.
-
explicit DocraftColor(float r, float g, float b, float a = 1.0F)
Creates a color from RGBA components.
- Parameters:
r – Red in [0,1].
g – Green in [0,1].
b – Blue in [0,1].
a – Alpha in [0,1].
-
explicit DocraftColor(const std::string &hex_code)
Creates a color from a hex code (#RRGGBB or #RRGGBBAA).
- Parameters:
hex_code – Hex string.
-
~DocraftColor() = default
Destructor.
-
ColorName toColorName() const
Returns the named color (if available).
- Returns:
ColorName enum value.
-
bool is_template_expression() const
Checks if this color is a template expression.
- Returns:
true if the color is a template expression like ${data(“field”)} or ${variable}
-
const std::string &template_expression() const
Gets the template expression string if this is a template color.
- Returns:
Template expression string (e.g., “${data(“field”)}”)
Public Static Functions
-
static DocraftColor fromColorName(ColorName name)
Creates a DocraftColor from a named color.
- Parameters:
name – Named color.
- Returns:
DocraftColor instance.
-
static DocraftColor fromRGB(float r, float g, float b, float a = 1.0F)
Creates a DocraftColor from RGBA components.
- Parameters:
r – Red in [0,1].
g – Green in [0,1].
b – Blue in [0,1].
a – Alpha in [0,1].
- Returns:
DocraftColor instance.
-
explicit DocraftColor(ColorName name = ColorName::kBlack)
RGB
DocraftCursor
Tracks the current 2D position for flow layout with a direction stack.
-
class DocraftCursor
Tracks the current position for flow layout.
The cursor stores a 2D point plus a stack of layout directions, enabling nested horizontal/vertical layout operations.
Public Functions
-
DocraftCursor()
Creates a cursor at origin with horizontal direction.
-
~DocraftCursor()
Destructor.
-
float x() const
Returns the current x position.
- Returns:
X coordinate.
-
float y() const
Returns the current y position.
- Returns:
Y coordinate.
-
DocraftCursorDirection direction() const
Returns the current direction.
- Returns:
Current cursor direction.
-
void reset_x()
Resets the x-coordinate of the cursor to 0.
-
void reset_y()
Resets the y-coordinate of the cursor to 0.
-
void set_x(float x)
Sets the x position.
- Parameters:
x – New x coordinate.
-
void set_y(float y)
Sets the y position.
- Parameters:
y – New y coordinate.
-
void push_direction(DocraftCursorDirection direction)
Pushes a new movement direction onto the stack.
- Parameters:
direction – Direction to push.
-
void pop_direction()
Pops the current direction, restoring the previous one.
-
void reset_direction()
Clears all direction hints, restoring default vertical flow.
-
void move_to(float x, float y)
Moves the cursor to the specified coordinates.
- Parameters:
x – New x coordinate.
y – New y coordinate.
-
DocraftCursor()
DocraftDocumentMetadata
Metadata container for PDF document information (author, title, dates, etc.).
Includes the nested DateTime struct for creation/modification dates.
-
class DocraftDocumentMetadata
Metadata container for PDF document information.
Supports all document info fields exposed by libharu (string attributes plus creation and modification dates).
Public Functions
-
inline void set_author(const std::string &author)
-
inline void set_creator(const std::string &creator)
-
inline void set_producer(const std::string &producer)
-
inline void set_title(const std::string &title)
-
inline void set_subject(const std::string &subject)
-
inline void set_keywords(const std::string &keywords)
-
inline void set_trapped(const std::string &trapped)
-
inline void set_gts_pdfx(const std::string >s_pdfx)
-
inline void clear_author()
-
inline void clear_creator()
-
inline void clear_producer()
-
inline void clear_title()
-
inline void clear_subject()
-
inline void clear_keywords()
-
inline void clear_trapped()
-
inline void clear_gts_pdfx()
-
inline void clear_creation_date()
-
inline void clear_modification_date()
-
inline const std::optional<std::string> &author() const
-
inline const std::optional<std::string> &creator() const
-
inline const std::optional<std::string> &producer() const
-
inline const std::optional<std::string> &title() const
-
inline const std::optional<std::string> &subject() const
-
inline const std::optional<std::string> &keywords() const
-
inline const std::optional<std::string> &trapped() const
-
inline const std::optional<std::string> >s_pdfx() const
-
struct DateTime
Date/time structure compatible with libharu info dates.
-
inline void set_author(const std::string &author)
DocraftPoint
DocraftAnchor
-
struct DocraftAnchor
Anchor points around a rectangle and its edges.
Public Members
-
DocraftPoint top_left
-
DocraftPoint top_center
-
DocraftPoint top_right
-
DocraftPoint bottom_left
-
DocraftPoint bottom_center
-
DocraftPoint bottom_right
-
DocraftPoint left_center
-
DocraftPoint right_center
-
DocraftPoint top_left
Enumerations
-
enum class docraft::ColorName
Named colors supported by the library.
Values:
-
enumerator kBlack
-
enumerator kWhite
-
enumerator kRed
-
enumerator kGreen
-
enumerator kBlue
-
enumerator kYellow
-
enumerator kMagenta
-
enumerator kCyan
-
enumerator kPurple
-
enumerator kBlack
-
enum class docraft::DocraftCursorDirection
Cursor movement direction hints for layout handlers.
Values:
-
enumerator kHorizontal
-
enumerator kVertical
-
enumerator kHorizontal
-
enum class docraft::model::ImageFormat
Supported image formats for DocraftImage.
Values:
-
enumerator kPng
-
enumerator kJpeg
-
enumerator kRaw
-
enumerator kPng
-
enum class docraft::model::LayoutOrientation
Layout orientation for child nodes.
Values:
-
enumerator kHorizontal
-
enumerator kVertical
-
enumerator kHorizontal
-
enum class docraft::model::ListKind
List kinds supported by Docraft.
Values:
-
enumerator kOrdered
-
enumerator kUnordered
-
enumerator kOrdered
-
enum class docraft::model::OrderedListStyle
Ordered list style variants.
Values:
-
enumerator kNumber
-
enumerator kRoman
-
enumerator kNumber
-
enum class docraft::model::UnorderedListDot
Unordered list marker shapes.
Values:
-
enumerator kDash
-
enumerator kStar
-
enumerator kCircle
-
enumerator kBox
-
enumerator kDash
-
enum class docraft::model::DocraftPageSize
Supported page sizes.
Values:
-
enumerator kA4
-
enumerator kA3
-
enumerator kA5
-
enumerator kLetter
-
enumerator kLegal
-
enumerator kA4
-
enum class docraft::model::DocraftPageOrientation
Page orientation.
Values:
-
enumerator kPortrait
-
enumerator kLandscape
-
enumerator kPortrait
-
enum class docraft::model::DocraftPositionType
Positioning modes for layout.
Values:
-
enumerator kBlock
-
enumerator kAbsolute
-
enumerator kBlock