pdfdom

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ElemBr

type ElemBr struct {
	// contains filtered or unexported fields
}

func NewElemBr

func NewElemBr() *ElemBr

func (*ElemBr) Add

func (b *ElemBr) Add(child PDFNode) error

func (*ElemBr) AddLine

func (b *ElemBr) AddLine(child PDFNode) error

func (*ElemBr) Attribute

func (b *ElemBr) Attribute(name string) (string, bool)

func (*ElemBr) ElementAttributes

func (b *ElemBr) ElementAttributes() []PDFNodeAttribute

func (*ElemBr) ElementChildLineBreaks

func (b *ElemBr) ElementChildLineBreaks() []bool

func (*ElemBr) ElementChildren

func (b *ElemBr) ElementChildren() []PDFNode

func (*ElemBr) ElementStyle

func (b *ElemBr) ElementStyle() *PDFTextStyle

func (*ElemBr) ElementType

func (e *ElemBr) ElementType() string

func (*ElemBr) SetAttribute

func (b *ElemBr) SetAttribute(name, value string) PDFElementNode

type ElemCol

type ElemCol struct {
	// contains filtered or unexported fields
}

func NewElemCol

func NewElemCol() *ElemCol

func (*ElemCol) Add

func (b *ElemCol) Add(child PDFNode) error

func (*ElemCol) AddLine

func (b *ElemCol) AddLine(child PDFNode) error

func (*ElemCol) Attribute

func (b *ElemCol) Attribute(name string) (string, bool)

func (*ElemCol) ElementAttributes

func (b *ElemCol) ElementAttributes() []PDFNodeAttribute

func (*ElemCol) ElementChildLineBreaks

func (b *ElemCol) ElementChildLineBreaks() []bool

func (*ElemCol) ElementChildren

func (b *ElemCol) ElementChildren() []PDFNode

func (*ElemCol) ElementStyle

func (b *ElemCol) ElementStyle() *PDFTextStyle

func (*ElemCol) ElementType

func (e *ElemCol) ElementType() string

func (*ElemCol) SetAttribute

func (b *ElemCol) SetAttribute(name, value string) PDFElementNode

type ElemColgroup

type ElemColgroup struct {
	// contains filtered or unexported fields
}

func NewElemColgroup

func NewElemColgroup() *ElemColgroup

func (*ElemColgroup) Add

func (b *ElemColgroup) Add(child PDFNode) error

func (*ElemColgroup) AddLine

func (b *ElemColgroup) AddLine(child PDFNode) error

func (*ElemColgroup) Attribute

func (b *ElemColgroup) Attribute(name string) (string, bool)

func (*ElemColgroup) ElementAttributes

func (b *ElemColgroup) ElementAttributes() []PDFNodeAttribute

func (*ElemColgroup) ElementChildLineBreaks

func (b *ElemColgroup) ElementChildLineBreaks() []bool

func (*ElemColgroup) ElementChildren

func (b *ElemColgroup) ElementChildren() []PDFNode

func (*ElemColgroup) ElementStyle

func (b *ElemColgroup) ElementStyle() *PDFTextStyle

func (*ElemColgroup) ElementType

func (e *ElemColgroup) ElementType() string

func (*ElemColgroup) SetAttribute

func (b *ElemColgroup) SetAttribute(name, value string) PDFElementNode

type ElemCreateTemplate

type ElemCreateTemplate struct {
	// contains filtered or unexported fields
}

func NewElemCreateTemplate

func NewElemCreateTemplate() *ElemCreateTemplate

func (*ElemCreateTemplate) Add

func (b *ElemCreateTemplate) Add(child PDFNode) error

func (*ElemCreateTemplate) AddLine

func (b *ElemCreateTemplate) AddLine(child PDFNode) error

func (*ElemCreateTemplate) Attribute

func (b *ElemCreateTemplate) Attribute(name string) (string, bool)

func (*ElemCreateTemplate) ElementAttributes

func (b *ElemCreateTemplate) ElementAttributes() []PDFNodeAttribute

func (*ElemCreateTemplate) ElementChildLineBreaks

func (b *ElemCreateTemplate) ElementChildLineBreaks() []bool

func (*ElemCreateTemplate) ElementChildren

func (b *ElemCreateTemplate) ElementChildren() []PDFNode

func (*ElemCreateTemplate) ElementStyle

func (b *ElemCreateTemplate) ElementStyle() *PDFTextStyle

func (*ElemCreateTemplate) ElementType

func (e *ElemCreateTemplate) ElementType() string

func (*ElemCreateTemplate) SetAttribute

func (b *ElemCreateTemplate) SetAttribute(name, value string) PDFElementNode

type ElemCurrencyValue

type ElemCurrencyValue struct {
	Value float64
	// contains filtered or unexported fields
}

ElemCurrencyValue formats a float64 as a locale-aware currency string.

func NewElemCurrencyValue

func NewElemCurrencyValue(value float64) *ElemCurrencyValue

func (*ElemCurrencyValue) Add

func (b *ElemCurrencyValue) Add(child PDFNode) error

func (*ElemCurrencyValue) AddLine

func (b *ElemCurrencyValue) AddLine(child PDFNode) error

func (*ElemCurrencyValue) Attribute

func (b *ElemCurrencyValue) Attribute(name string) (string, bool)

func (*ElemCurrencyValue) ElementAttributes

func (b *ElemCurrencyValue) ElementAttributes() []PDFNodeAttribute

func (*ElemCurrencyValue) ElementChildLineBreaks

func (b *ElemCurrencyValue) ElementChildLineBreaks() []bool

func (*ElemCurrencyValue) ElementChildren

func (b *ElemCurrencyValue) ElementChildren() []PDFNode

func (*ElemCurrencyValue) ElementStyle

func (b *ElemCurrencyValue) ElementStyle() *PDFTextStyle

func (*ElemCurrencyValue) ElementType

func (e *ElemCurrencyValue) ElementType() string

func (*ElemCurrencyValue) Format

func (e *ElemCurrencyValue) Format(formatter ValueFormatter) string

Format returns the locale-formatted currency string.

func (*ElemCurrencyValue) SetAttribute

func (b *ElemCurrencyValue) SetAttribute(name, value string) PDFElementNode

type ElemDateValue

type ElemDateValue struct {
	Value string
	// contains filtered or unexported fields
}

ElemDateValue formats an ISO-8601 date string ("2006-01-02"). Attribute "long" = "true" selects the long date format.

func NewElemDateValue

func NewElemDateValue(dateStr string) *ElemDateValue

func (*ElemDateValue) Add

func (b *ElemDateValue) Add(child PDFNode) error

func (*ElemDateValue) AddLine

func (b *ElemDateValue) AddLine(child PDFNode) error

func (*ElemDateValue) Attribute

func (b *ElemDateValue) Attribute(name string) (string, bool)

func (*ElemDateValue) ElementAttributes

func (b *ElemDateValue) ElementAttributes() []PDFNodeAttribute

func (*ElemDateValue) ElementChildLineBreaks

func (b *ElemDateValue) ElementChildLineBreaks() []bool

func (*ElemDateValue) ElementChildren

func (b *ElemDateValue) ElementChildren() []PDFNode

func (*ElemDateValue) ElementStyle

func (b *ElemDateValue) ElementStyle() *PDFTextStyle

func (*ElemDateValue) ElementType

func (e *ElemDateValue) ElementType() string

func (*ElemDateValue) Format

func (e *ElemDateValue) Format(formatter ValueFormatter) string

Format returns the formatted date, using long format when requested.

func (*ElemDateValue) SetAttribute

func (b *ElemDateValue) SetAttribute(name, value string) PDFElementNode

type ElemDiv

type ElemDiv struct {
	// contains filtered or unexported fields
}

func NewElemDiv

func NewElemDiv() *ElemDiv

func ParseHTMLSectionElem

func ParseHTMLSectionElem(htmlStr, cssStyle string) (*ElemDiv, error)

ParseHTMLSectionElem parses an HTML fragment containing a <div id="intro"> element with <span>, <div> and <br> children and maps it to an ElemDiv. cssStyle is applied before parsing (may be empty).

func (*ElemDiv) Add

func (b *ElemDiv) Add(child PDFNode) error

func (*ElemDiv) AddLine

func (b *ElemDiv) AddLine(child PDFNode) error

func (*ElemDiv) Attribute

func (b *ElemDiv) Attribute(name string) (string, bool)

func (*ElemDiv) ElementAttributes

func (b *ElemDiv) ElementAttributes() []PDFNodeAttribute

func (*ElemDiv) ElementChildLineBreaks

func (b *ElemDiv) ElementChildLineBreaks() []bool

func (*ElemDiv) ElementChildren

func (b *ElemDiv) ElementChildren() []PDFNode

func (*ElemDiv) ElementStyle

func (b *ElemDiv) ElementStyle() *PDFTextStyle

func (*ElemDiv) ElementType

func (e *ElemDiv) ElementType() string

func (*ElemDiv) SetAttribute

func (b *ElemDiv) SetAttribute(name, value string) PDFElementNode

type ElemDurationValue

type ElemDurationValue struct {
	Value float64
	// contains filtered or unexported fields
}

ElemDurationValue formats hours as "H:MM" duration text.

func NewElemDurationValue

func NewElemDurationValue(hours float64) *ElemDurationValue

func (*ElemDurationValue) Add

func (b *ElemDurationValue) Add(child PDFNode) error

func (*ElemDurationValue) AddLine

func (b *ElemDurationValue) AddLine(child PDFNode) error

func (*ElemDurationValue) Attribute

func (b *ElemDurationValue) Attribute(name string) (string, bool)

func (*ElemDurationValue) ElementAttributes

func (b *ElemDurationValue) ElementAttributes() []PDFNodeAttribute

func (*ElemDurationValue) ElementChildLineBreaks

func (b *ElemDurationValue) ElementChildLineBreaks() []bool

func (*ElemDurationValue) ElementChildren

func (b *ElemDurationValue) ElementChildren() []PDFNode

func (*ElemDurationValue) ElementStyle

func (b *ElemDurationValue) ElementStyle() *PDFTextStyle

func (*ElemDurationValue) ElementType

func (e *ElemDurationValue) ElementType() string

func (*ElemDurationValue) Format

func (e *ElemDurationValue) Format(formatter ValueFormatter) string

Format returns the duration as "H:MM".

func (*ElemDurationValue) SetAttribute

func (b *ElemDurationValue) SetAttribute(name, value string) PDFElementNode

type ElemH1

type ElemH1 struct {
	// contains filtered or unexported fields
}

func NewElemH1

func NewElemH1() *ElemH1

func (*ElemH1) Add

func (b *ElemH1) Add(child PDFNode) error

func (*ElemH1) AddLine

func (b *ElemH1) AddLine(child PDFNode) error

func (*ElemH1) Attribute

func (b *ElemH1) Attribute(name string) (string, bool)

func (*ElemH1) ElementAttributes

func (b *ElemH1) ElementAttributes() []PDFNodeAttribute

func (*ElemH1) ElementChildLineBreaks

func (b *ElemH1) ElementChildLineBreaks() []bool

func (*ElemH1) ElementChildren

func (b *ElemH1) ElementChildren() []PDFNode

func (*ElemH1) ElementStyle

func (b *ElemH1) ElementStyle() *PDFTextStyle

func (*ElemH1) ElementType

func (e *ElemH1) ElementType() string

func (*ElemH1) SetAttribute

func (b *ElemH1) SetAttribute(name, value string) PDFElementNode

type ElemH2

type ElemH2 struct {
	// contains filtered or unexported fields
}

func NewElemH2

func NewElemH2() *ElemH2

func (*ElemH2) Add

func (b *ElemH2) Add(child PDFNode) error

func (*ElemH2) AddLine

func (b *ElemH2) AddLine(child PDFNode) error

func (*ElemH2) Attribute

func (b *ElemH2) Attribute(name string) (string, bool)

func (*ElemH2) ElementAttributes

func (b *ElemH2) ElementAttributes() []PDFNodeAttribute

func (*ElemH2) ElementChildLineBreaks

func (b *ElemH2) ElementChildLineBreaks() []bool

func (*ElemH2) ElementChildren

func (b *ElemH2) ElementChildren() []PDFNode

func (*ElemH2) ElementStyle

func (b *ElemH2) ElementStyle() *PDFTextStyle

func (*ElemH2) ElementType

func (e *ElemH2) ElementType() string

func (*ElemH2) SetAttribute

func (b *ElemH2) SetAttribute(name, value string) PDFElementNode

type ElemH3

type ElemH3 struct {
	// contains filtered or unexported fields
}

func NewElemH3

func NewElemH3() *ElemH3

func (*ElemH3) Add

func (b *ElemH3) Add(child PDFNode) error

func (*ElemH3) AddLine

func (b *ElemH3) AddLine(child PDFNode) error

func (*ElemH3) Attribute

func (b *ElemH3) Attribute(name string) (string, bool)

func (*ElemH3) ElementAttributes

func (b *ElemH3) ElementAttributes() []PDFNodeAttribute

func (*ElemH3) ElementChildLineBreaks

func (b *ElemH3) ElementChildLineBreaks() []bool

func (*ElemH3) ElementChildren

func (b *ElemH3) ElementChildren() []PDFNode

func (*ElemH3) ElementStyle

func (b *ElemH3) ElementStyle() *PDFTextStyle

func (*ElemH3) ElementType

func (e *ElemH3) ElementType() string

func (*ElemH3) SetAttribute

func (b *ElemH3) SetAttribute(name, value string) PDFElementNode

type ElemImg

type ElemImg struct {
	// contains filtered or unexported fields
}

func NewElemImg

func NewElemImg() *ElemImg

func (*ElemImg) Add

func (b *ElemImg) Add(child PDFNode) error

func (*ElemImg) AddLine

func (b *ElemImg) AddLine(child PDFNode) error

func (*ElemImg) Attribute

func (b *ElemImg) Attribute(name string) (string, bool)

func (*ElemImg) ElementAttributes

func (b *ElemImg) ElementAttributes() []PDFNodeAttribute

func (*ElemImg) ElementChildLineBreaks

func (b *ElemImg) ElementChildLineBreaks() []bool

func (*ElemImg) ElementChildren

func (b *ElemImg) ElementChildren() []PDFNode

func (*ElemImg) ElementStyle

func (b *ElemImg) ElementStyle() *PDFTextStyle

func (*ElemImg) ElementType

func (e *ElemImg) ElementType() string

func (*ElemImg) SetAttribute

func (b *ElemImg) SetAttribute(name, value string) PDFElementNode

type ElemLi

type ElemLi struct {
	// contains filtered or unexported fields
}

func NewElemLi

func NewElemLi() *ElemLi

func (*ElemLi) Add

func (b *ElemLi) Add(child PDFNode) error

func (*ElemLi) AddLine

func (b *ElemLi) AddLine(child PDFNode) error

func (*ElemLi) Attribute

func (b *ElemLi) Attribute(name string) (string, bool)

func (*ElemLi) ElementAttributes

func (b *ElemLi) ElementAttributes() []PDFNodeAttribute

func (*ElemLi) ElementChildLineBreaks

func (b *ElemLi) ElementChildLineBreaks() []bool

func (*ElemLi) ElementChildren

func (b *ElemLi) ElementChildren() []PDFNode

func (*ElemLi) ElementStyle

func (b *ElemLi) ElementStyle() *PDFTextStyle

func (*ElemLi) ElementType

func (e *ElemLi) ElementType() string

func (*ElemLi) SetAttribute

func (b *ElemLi) SetAttribute(name, value string) PDFElementNode

type ElemManDaysValue

type ElemManDaysValue struct {
	Value float64
	// contains filtered or unexported fields
}

ElemManDaysValue formats a man-days quantity with locale-aware decimal formatting and an optional " PT" (Personentage) unit suffix. Attribute "unit" = "true" appends the unit suffix.

func NewElemManDaysValue

func NewElemManDaysValue(days float64) *ElemManDaysValue

func (*ElemManDaysValue) Add

func (b *ElemManDaysValue) Add(child PDFNode) error

func (*ElemManDaysValue) AddLine

func (b *ElemManDaysValue) AddLine(child PDFNode) error

func (*ElemManDaysValue) Attribute

func (b *ElemManDaysValue) Attribute(name string) (string, bool)

func (*ElemManDaysValue) ElementAttributes

func (b *ElemManDaysValue) ElementAttributes() []PDFNodeAttribute

func (*ElemManDaysValue) ElementChildLineBreaks

func (b *ElemManDaysValue) ElementChildLineBreaks() []bool

func (*ElemManDaysValue) ElementChildren

func (b *ElemManDaysValue) ElementChildren() []PDFNode

func (*ElemManDaysValue) ElementStyle

func (b *ElemManDaysValue) ElementStyle() *PDFTextStyle

func (*ElemManDaysValue) ElementType

func (e *ElemManDaysValue) ElementType() string

func (*ElemManDaysValue) Format

func (e *ElemManDaysValue) Format(formatter ValueFormatter) string

Format returns man-days with an optional " PT" suffix.

func (*ElemManDaysValue) SetAttribute

func (b *ElemManDaysValue) SetAttribute(name, value string) PDFElementNode

type ElemOl

type ElemOl struct {
	// contains filtered or unexported fields
}

func NewElemOl

func NewElemOl() *ElemOl

func (*ElemOl) Add

func (b *ElemOl) Add(child PDFNode) error

func (*ElemOl) AddLine

func (b *ElemOl) AddLine(child PDFNode) error

func (*ElemOl) Attribute

func (b *ElemOl) Attribute(name string) (string, bool)

func (*ElemOl) ElementAttributes

func (b *ElemOl) ElementAttributes() []PDFNodeAttribute

func (*ElemOl) ElementChildLineBreaks

func (b *ElemOl) ElementChildLineBreaks() []bool

func (*ElemOl) ElementChildren

func (b *ElemOl) ElementChildren() []PDFNode

func (*ElemOl) ElementStyle

func (b *ElemOl) ElementStyle() *PDFTextStyle

func (*ElemOl) ElementType

func (e *ElemOl) ElementType() string

func (*ElemOl) SetAttribute

func (b *ElemOl) SetAttribute(name, value string) PDFElementNode

type ElemSpan

type ElemSpan struct {
	// contains filtered or unexported fields
}

func NewElemSpan

func NewElemSpan() *ElemSpan

func (*ElemSpan) Add

func (b *ElemSpan) Add(child PDFNode) error

func (*ElemSpan) AddLine

func (b *ElemSpan) AddLine(child PDFNode) error

func (*ElemSpan) Attribute

func (b *ElemSpan) Attribute(name string) (string, bool)

func (*ElemSpan) ElementAttributes

func (b *ElemSpan) ElementAttributes() []PDFNodeAttribute

func (*ElemSpan) ElementChildLineBreaks

func (b *ElemSpan) ElementChildLineBreaks() []bool

func (*ElemSpan) ElementChildren

func (b *ElemSpan) ElementChildren() []PDFNode

func (*ElemSpan) ElementStyle

func (b *ElemSpan) ElementStyle() *PDFTextStyle

func (*ElemSpan) ElementType

func (e *ElemSpan) ElementType() string

func (*ElemSpan) SetAttribute

func (b *ElemSpan) SetAttribute(name, value string) PDFElementNode

type ElemTable

type ElemTable struct {
	// contains filtered or unexported fields
}

func NewElemTable

func NewElemTable() *ElemTable

func ParseHTMLTableElem

func ParseHTMLTableElem(htmlStr, cssStyle string) (*ElemTable, error)

ParseHTMLTableElem parses an HTML fragment containing a <table> element and maps it to the same ElemTable / Elem* node tree used by the PDF rendering pipeline. cssStyle is applied before parsing (may be empty).

Mapping rules:

<table>               → ElemTable       (all attributes forwarded)
<colgroup>            → ElemColgroup
<col>                 → ElemCol         (width attribute forwarded)
<thead>               → ElemThead
<tbody>               → ElemTbody
<tr>                  → ElemTr          (fill, stroke, height forwarded)
<td>                  → ElemTd          (align, colspan forwarded)
<th>                  → ElemTh          (align, colspan forwarded)
<span>                → PDFTextNode     (font-style/face/size/color/align
                                         become PDFTextStyle fields)
<currency-value>      → ElemCurrencyValue  ("v" attr → Value float64)
<date-value>          → ElemDateValue      ("value" attr → Value string;
                                             "long" attr forwarded)
<duration-value>      → ElemDurationValue  ("v" attr → Value float64)
<man-days-value>      → ElemManDaysValue   ("v" attr → Value float64;
                                             "unit" attr forwarded)

Attribute name normalisation (HTML kebab-case → Elem* camelCase):

row-height-min → rowHeightMin

Inside <td>, the first non-empty child is added inline (Add); each subsequent child is added with a preceding line break (AddLine), matching the main-text / sub-text rendering idiom.

func (*ElemTable) Add

func (b *ElemTable) Add(child PDFNode) error

func (*ElemTable) AddLine

func (b *ElemTable) AddLine(child PDFNode) error

func (*ElemTable) Attribute

func (b *ElemTable) Attribute(name string) (string, bool)

func (*ElemTable) ElementAttributes

func (b *ElemTable) ElementAttributes() []PDFNodeAttribute

func (*ElemTable) ElementChildLineBreaks

func (b *ElemTable) ElementChildLineBreaks() []bool

func (*ElemTable) ElementChildren

func (b *ElemTable) ElementChildren() []PDFNode

func (*ElemTable) ElementStyle

func (b *ElemTable) ElementStyle() *PDFTextStyle

func (*ElemTable) ElementType

func (e *ElemTable) ElementType() string

func (*ElemTable) SetAttribute

func (b *ElemTable) SetAttribute(name, value string) PDFElementNode

type ElemTbody

type ElemTbody struct {
	// contains filtered or unexported fields
}

func NewElemTbody

func NewElemTbody() *ElemTbody

func (*ElemTbody) Add

func (b *ElemTbody) Add(child PDFNode) error

func (*ElemTbody) AddLine

func (b *ElemTbody) AddLine(child PDFNode) error

func (*ElemTbody) Attribute

func (b *ElemTbody) Attribute(name string) (string, bool)

func (*ElemTbody) ElementAttributes

func (b *ElemTbody) ElementAttributes() []PDFNodeAttribute

func (*ElemTbody) ElementChildLineBreaks

func (b *ElemTbody) ElementChildLineBreaks() []bool

func (*ElemTbody) ElementChildren

func (b *ElemTbody) ElementChildren() []PDFNode

func (*ElemTbody) ElementStyle

func (b *ElemTbody) ElementStyle() *PDFTextStyle

func (*ElemTbody) ElementType

func (e *ElemTbody) ElementType() string

func (*ElemTbody) SetAttribute

func (b *ElemTbody) SetAttribute(name, value string) PDFElementNode

type ElemTd

type ElemTd struct {
	// contains filtered or unexported fields
}

func NewElemTd

func NewElemTd() *ElemTd

func (*ElemTd) Add

func (b *ElemTd) Add(child PDFNode) error

func (*ElemTd) AddLine

func (b *ElemTd) AddLine(child PDFNode) error

func (*ElemTd) Attribute

func (b *ElemTd) Attribute(name string) (string, bool)

func (*ElemTd) ElementAttributes

func (b *ElemTd) ElementAttributes() []PDFNodeAttribute

func (*ElemTd) ElementChildLineBreaks

func (b *ElemTd) ElementChildLineBreaks() []bool

func (*ElemTd) ElementChildren

func (b *ElemTd) ElementChildren() []PDFNode

func (*ElemTd) ElementStyle

func (b *ElemTd) ElementStyle() *PDFTextStyle

func (*ElemTd) ElementType

func (e *ElemTd) ElementType() string

func (*ElemTd) SetAttribute

func (b *ElemTd) SetAttribute(name, value string) PDFElementNode

type ElemTh

type ElemTh struct {
	// contains filtered or unexported fields
}

func NewElemTh

func NewElemTh() *ElemTh

func (*ElemTh) Add

func (b *ElemTh) Add(child PDFNode) error

func (*ElemTh) AddLine

func (b *ElemTh) AddLine(child PDFNode) error

func (*ElemTh) Attribute

func (b *ElemTh) Attribute(name string) (string, bool)

func (*ElemTh) ElementAttributes

func (b *ElemTh) ElementAttributes() []PDFNodeAttribute

func (*ElemTh) ElementChildLineBreaks

func (b *ElemTh) ElementChildLineBreaks() []bool

func (*ElemTh) ElementChildren

func (b *ElemTh) ElementChildren() []PDFNode

func (*ElemTh) ElementStyle

func (b *ElemTh) ElementStyle() *PDFTextStyle

func (*ElemTh) ElementType

func (e *ElemTh) ElementType() string

func (*ElemTh) SetAttribute

func (b *ElemTh) SetAttribute(name, value string) PDFElementNode

type ElemThead

type ElemThead struct {
	// contains filtered or unexported fields
}

func NewElemThead

func NewElemThead() *ElemThead

func (*ElemThead) Add

func (b *ElemThead) Add(child PDFNode) error

func (*ElemThead) AddLine

func (b *ElemThead) AddLine(child PDFNode) error

func (*ElemThead) Attribute

func (b *ElemThead) Attribute(name string) (string, bool)

func (*ElemThead) ElementAttributes

func (b *ElemThead) ElementAttributes() []PDFNodeAttribute

func (*ElemThead) ElementChildLineBreaks

func (b *ElemThead) ElementChildLineBreaks() []bool

func (*ElemThead) ElementChildren

func (b *ElemThead) ElementChildren() []PDFNode

func (*ElemThead) ElementStyle

func (b *ElemThead) ElementStyle() *PDFTextStyle

func (*ElemThead) ElementType

func (e *ElemThead) ElementType() string

func (*ElemThead) SetAttribute

func (b *ElemThead) SetAttribute(name, value string) PDFElementNode

type ElemTr

type ElemTr struct {
	// contains filtered or unexported fields
}

func NewElemTr

func NewElemTr() *ElemTr

func (*ElemTr) Add

func (b *ElemTr) Add(child PDFNode) error

func (*ElemTr) AddLine

func (b *ElemTr) AddLine(child PDFNode) error

func (*ElemTr) Attribute

func (b *ElemTr) Attribute(name string) (string, bool)

func (*ElemTr) ElementAttributes

func (b *ElemTr) ElementAttributes() []PDFNodeAttribute

func (*ElemTr) ElementChildLineBreaks

func (b *ElemTr) ElementChildLineBreaks() []bool

func (*ElemTr) ElementChildren

func (b *ElemTr) ElementChildren() []PDFNode

func (*ElemTr) ElementStyle

func (b *ElemTr) ElementStyle() *PDFTextStyle

func (*ElemTr) ElementType

func (e *ElemTr) ElementType() string

func (*ElemTr) SetAttribute

func (b *ElemTr) SetAttribute(name, value string) PDFElementNode

type ElemUl

type ElemUl struct {
	// contains filtered or unexported fields
}

func NewElemUl

func NewElemUl() *ElemUl

func (*ElemUl) Add

func (b *ElemUl) Add(child PDFNode) error

func (*ElemUl) AddLine

func (b *ElemUl) AddLine(child PDFNode) error

func (*ElemUl) Attribute

func (b *ElemUl) Attribute(name string) (string, bool)

func (*ElemUl) ElementAttributes

func (b *ElemUl) ElementAttributes() []PDFNodeAttribute

func (*ElemUl) ElementChildLineBreaks

func (b *ElemUl) ElementChildLineBreaks() []bool

func (*ElemUl) ElementChildren

func (b *ElemUl) ElementChildren() []PDFNode

func (*ElemUl) ElementStyle

func (b *ElemUl) ElementStyle() *PDFTextStyle

func (*ElemUl) ElementType

func (e *ElemUl) ElementType() string

func (*ElemUl) SetAttribute

func (b *ElemUl) SetAttribute(name, value string) PDFElementNode

type ElemUseTemplate

type ElemUseTemplate struct {
	// contains filtered or unexported fields
}

func NewElemUseTemplate

func NewElemUseTemplate() *ElemUseTemplate

func (*ElemUseTemplate) Add

func (b *ElemUseTemplate) Add(child PDFNode) error

func (*ElemUseTemplate) AddLine

func (b *ElemUseTemplate) AddLine(child PDFNode) error

func (*ElemUseTemplate) Attribute

func (b *ElemUseTemplate) Attribute(name string) (string, bool)

func (*ElemUseTemplate) ElementAttributes

func (b *ElemUseTemplate) ElementAttributes() []PDFNodeAttribute

func (*ElemUseTemplate) ElementChildLineBreaks

func (b *ElemUseTemplate) ElementChildLineBreaks() []bool

func (*ElemUseTemplate) ElementChildren

func (b *ElemUseTemplate) ElementChildren() []PDFNode

func (*ElemUseTemplate) ElementStyle

func (b *ElemUseTemplate) ElementStyle() *PDFTextStyle

func (*ElemUseTemplate) ElementType

func (e *ElemUseTemplate) ElementType() string

func (*ElemUseTemplate) SetAttribute

func (b *ElemUseTemplate) SetAttribute(name, value string) PDFElementNode

type PDFDocumentNode

type PDFDocumentNode struct {
	Style           *PDFTextStyle
	Children        []PDFNode
	ChildLineBreaks []bool
}

PDFDocumentNode is the root node and may contain element and text nodes.

func (*PDFDocumentNode) Add

func (d *PDFDocumentNode) Add(child PDFNode) *PDFDocumentNode

Add appends a child node inline (no implicit newline).

func (*PDFDocumentNode) AddLine

func (d *PDFDocumentNode) AddLine(child PDFNode) *PDFDocumentNode

AddLine appends a child node and inserts an implicit newline before it.

type PDFElementNode

type PDFElementNode interface {
	PDFNode
	ElementType() string
	ElementStyle() *PDFTextStyle
	ElementChildren() []PDFNode
	ElementChildLineBreaks() []bool
	ElementAttributes() []PDFNodeAttribute
	SetAttribute(name, value string) PDFElementNode
	Attribute(name string) (string, bool)
	Add(child PDFNode) error
	AddLine(child PDFNode) error
	// contains filtered or unexported methods
}

PDFElementNode is implemented by typed HTML-like container elements.

func ParseHTMLDocFlow

func ParseHTMLDocFlow(htmlStr, cssStyle string) ([]PDFElementNode, error)

ParseHTMLDocFlow parses an HTML fragment into top-level renderable elements in source order. cssStyle is applied before parsing (may be empty). Supported root-level tags are <div>, <footer>, <p>, <table>, <img>, and headings <h1>..<h3>.

func ParseHTMLDocFlowPrepared

func ParseHTMLDocFlowPrepared(htmlString string, stylesheet *tmpl.PreparedStylesheet) ([]PDFElementNode, error)

func ParseHTMLDocFlowPreparedWithOptions

func ParseHTMLDocFlowPreparedWithOptions(htmlString string, stylesheet *tmpl.PreparedStylesheet, options ParseOptions) ([]PDFElementNode, error)

type PDFNode

type PDFNode interface {
	// contains filtered or unexported methods
}

PDFNode is implemented by all declarative document/text tree nodes.

type PDFNodeAttribute

type PDFNodeAttribute struct {
	Name  string
	Value string
}

PDFNodeAttribute defines an element attribute (name/value).

type PDFText

type PDFText = PDFTextNode

PDFText is kept as a compatibility alias for existing call sites.

type PDFTextBox

type PDFTextBox struct {
	X      float64
	Y      float64
	Width  float64
	Height float64
	Fit    TextFitMode
}

PDFTextBox defines the desired bounding box and fit strategy.

type PDFTextNode

type PDFTextNode struct {
	Text     string
	I18nKey  string
	I18nVars map[string]string
	Style    *PDFTextStyle
	Children []PDFNode
	// ChildLineBreaks stores whether a line break should be inserted before a
	// child at the same index in Children.
	ChildLineBreaks []bool
}

PDFTextNode is a declarative text node that can contain child text nodes.

func (*PDFTextNode) Add

func (t *PDFTextNode) Add(child PDFNode) *PDFTextNode

Add appends a child node inline (no implicit newline).

func (*PDFTextNode) AddLine

func (t *PDFTextNode) AddLine(child PDFNode) *PDFTextNode

AddLine appends a child node and inserts an implicit newline before it.

type PDFTextStyle

type PDFTextStyle struct {
	FontFace        string
	FontStyle       string
	FontStyleSet    bool
	FontSize        float64
	FontColor       string
	Align           TextAlign
	LineHeight      float64
	BackgroundColor string
	BorderColor     string
	BorderStyle     string
	BorderWidth     float64
}

PDFTextStyle defines text styling and supports inheritance.

func (PDFTextStyle) Merge

func (base PDFTextStyle) Merge(override *PDFTextStyle) PDFTextStyle

Merge returns a style where missing values from override are inherited from base.

type ParseOptions

type ParseOptions struct {
	AllowInvalidSpanAttributes bool
	Warnf                      func(string, ...any)
}

type StyleVariant

type StyleVariant struct {
	FontFace  string
	FontColor string
	FontSize  int
}

StyleVariant holds the font rendering attributes for a single named style variant (Normal, Small, Title, etc.). It is defined here so that pdflayout can use it without importing the invoice package.

type TextAlign

type TextAlign string

TextAlign controls horizontal text alignment inside a bounding box.

const (
	TextAlignLeft   TextAlign = "left"
	TextAlignCenter TextAlign = "center"
	TextAlignRight  TextAlign = "right"
)

type TextFitMode

type TextFitMode string

TextFitMode controls how text behaves inside a constrained width/height.

const (
	TextFitWrap TextFitMode = "wrap"
	TextFitClip TextFitMode = "clip"
)

type Translator

type Translator interface {
	T(key string) string
	TWithVars(key string, vars map[string]string) string
}

Translator resolves i18n keys to their translated strings. Implemented by *invoice.I18n; defined here to avoid an import cycle.

type ValueFormatter

type ValueFormatter interface {
	FormatCurrency(value float64) string
	FormatDate(dateStr string, long bool) string
	FormatDuration(hours float64) string
	FormatFloat(value float64, decimals int) string
}

ValueFormatter formats typed domain values for rendering. Implemented by *invoice.Formatter; defined here to avoid an import cycle.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL