Documentation
¶
Index ¶
- func AddFontFamiliesFromCSS(cs *csshtml.CSS, fe *frontend.Document) error
- func ApplySettings(settings frontend.TypesettingSettings, ih *FormattingStyles)
- func GetHTMLItemFromHTMLNode(thisNode *html.Node, direction Mode, firstItem *HTMLItem) error
- func HTMLNodeToText(n *html.Node, ss StylesStack, df *frontend.Document) (*frontend.Text, error)
- func LoadIncludedFonts(fe *frontend.Document) error
- func Output(item *HTMLItem, ss StylesStack, df *frontend.Document) (*frontend.Text, error)
- func ParseHorizontalAlign(align string, styles *FormattingStyles) frontend.HorizontalAlignment
- func ParseRelativeSize(fs string, cur bag.ScaledPoint, root bag.ScaledPoint) bag.ScaledPoint
- func ParseVerticalAlign(align string, styles *FormattingStyles) frontend.VerticalAlignment
- func StylesToStyles(ih *FormattingStyles, attributes map[string]string, df *frontend.Document, ...) error
- type CSSBuilder
- func (cb *CSSBuilder) AddCSS(css string) error
- func (cb *CSSBuilder) BeforeShipout() error
- func (cb *CSSBuilder) CSSPropertiesToValues(p HTMLProperties) HTMLValues
- func (cb *CSSBuilder) CreateVlist(te *frontend.Text, wd bag.ScaledPoint) (*node.VList, error)
- func (cb *CSSBuilder) HTMLBorder(vl *node.VList, hv HTMLValues) *node.VList
- func (cb *CSSBuilder) HTMLToText(html string) (*frontend.Text, error)
- func (cb *CSSBuilder) InitPage() error
- func (cb *CSSBuilder) NewPage() error
- func (cb *CSSBuilder) PageSize() (PageDimensions, error)
- func (cb *CSSBuilder) ParseCSSString(css string) error
- func (cb *CSSBuilder) ParseHTMLFromNode(input *html.Node) (*frontend.Text, error)
- func (cb *CSSBuilder) ReadCSSFile(filename string) error
- type FormattingStyles
- type HTMLItem
- type HTMLProperties
- type HTMLValues
- type Mode
- type PageDimensions
- type StylesStack
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddFontFamiliesFromCSS ¶
AddFontFamiliesFromCSS adds entries to the font families of the frontend document.
func ApplySettings ¶
func ApplySettings(settings frontend.TypesettingSettings, ih *FormattingStyles)
ApplySettings converts the inheritable settings to boxes and glue text settings.
func GetHTMLItemFromHTMLNode ¶
GetHTMLItemFromHTMLNode fills the firstItem with the contents of thisNode. Comments and DocumentNodes are ignored.
func HTMLNodeToText ¶
HTMLNodeToText converts an HTML node to a *frontend.Text element.
func LoadIncludedFonts ¶
LoadIncludedFonts creates the font families monospace, sans and serif for default fonts.
func ParseHorizontalAlign ¶
func ParseHorizontalAlign(align string, styles *FormattingStyles) frontend.HorizontalAlignment
ParseHorizontalAlign parses the input ("left","center") and returns the HorizontalAlignment value.
func ParseRelativeSize ¶
func ParseRelativeSize(fs string, cur bag.ScaledPoint, root bag.ScaledPoint) bag.ScaledPoint
ParseRelativeSize converts the string fs to a scaled point. This can be an absolute size like 12pt but also a size like 1.2 or 2em. The provided dflt is the source size. The root is the document's default value.
func ParseVerticalAlign ¶
func ParseVerticalAlign(align string, styles *FormattingStyles) frontend.VerticalAlignment
ParseVerticalAlign parses the input ("top","middle",...) and returns the VerticalAlignment value.
func StylesToStyles ¶
func StylesToStyles(ih *FormattingStyles, attributes map[string]string, df *frontend.Document, curFontSize bag.ScaledPoint) error
StylesToStyles updates the inheritable formattingStyles from the attributes (of the current HTML element).
Types ¶
type CSSBuilder ¶
type CSSBuilder struct {
// contains filtered or unexported fields
}
CSSBuilder handles HTML chunks and CSS instructions.
func (*CSSBuilder) AddCSS ¶
func (cb *CSSBuilder) AddCSS(css string) error
AddCSS reads the CSS instructions in css.
func (*CSSBuilder) BeforeShipout ¶
func (cb *CSSBuilder) BeforeShipout() error
BeforeShipout should be called when placing a CSS page in the PDF. It adds page margin boxes to the current page.
func (*CSSBuilder) CSSPropertiesToValues ¶
func (cb *CSSBuilder) CSSPropertiesToValues(p HTMLProperties) HTMLValues
CSSPropertiesToValues converts CSS values to the HTMLValues struct.
func (*CSSBuilder) CreateVlist ¶
func (cb *CSSBuilder) CreateVlist(te *frontend.Text, wd bag.ScaledPoint) (*node.VList, error)
CreateVlist builds a vlist (a vertical list) from the Text object.
func (*CSSBuilder) HTMLBorder ¶
func (cb *CSSBuilder) HTMLBorder(vl *node.VList, hv HTMLValues) *node.VList
HTMLBorder returns two string with a HTML border. The first string is part of a prefix for a possible background string and the second string renders the border.
func (*CSSBuilder) HTMLToText ¶
func (cb *CSSBuilder) HTMLToText(html string) (*frontend.Text, error)
HTMLToText interprets the HTML string and applies all previously read CSS data.
func (*CSSBuilder) InitPage ¶
func (cb *CSSBuilder) InitPage() error
InitPage makes sure that there is a valid page in the frontend.
func (*CSSBuilder) NewPage ¶
func (cb *CSSBuilder) NewPage() error
NewPage puts the current page into the PDF document and starts with a new page.
func (*CSSBuilder) PageSize ¶
func (cb *CSSBuilder) PageSize() (PageDimensions, error)
PageSize returns a struct with the dimensions of the current page.
func (*CSSBuilder) ParseCSSString ¶
func (cb *CSSBuilder) ParseCSSString(css string) error
ParseCSSString reads CSS instructions from a string.
func (*CSSBuilder) ParseHTMLFromNode ¶
ParseHTMLFromNode interprets the HTML structure and applies all previously read CSS data.
func (*CSSBuilder) ReadCSSFile ¶
func (cb *CSSBuilder) ReadCSSFile(filename string) error
ReadCSSFile reads the given file name and tries to parse the CSS contents from the file.
type FormattingStyles ¶
type FormattingStyles struct {
BackgroundColor *color.Color
BorderLeftWidth bag.ScaledPoint
BorderRightWidth bag.ScaledPoint
BorderBottomWidth bag.ScaledPoint
BorderTopWidth bag.ScaledPoint
BorderTopLeftRadius bag.ScaledPoint
BorderTopRightRadius bag.ScaledPoint
BorderBottomLeftRadius bag.ScaledPoint
BorderBottomRightRadius bag.ScaledPoint
BorderLeftColor *color.Color
BorderRightColor *color.Color
BorderBottomColor *color.Color
BorderTopColor *color.Color
BorderLeftStyle frontend.BorderStyle
BorderRightStyle frontend.BorderStyle
BorderBottomStyle frontend.BorderStyle
BorderTopStyle frontend.BorderStyle
DefaultFontSize bag.ScaledPoint
DefaultFontFamily *frontend.FontFamily
Hide bool
Fontsize bag.ScaledPoint
Fontweight frontend.FontWeight
Halign frontend.HorizontalAlignment
ListStyleType string
OlCounter int
ListPaddingLeft bag.ScaledPoint
PaddingBottom bag.ScaledPoint
PaddingLeft bag.ScaledPoint
PaddingRight bag.ScaledPoint
PaddingTop bag.ScaledPoint
TextDecorationLine frontend.TextDecorationLine
Valign frontend.VerticalAlignment
// contains filtered or unexported fields
}
FormattingStyles are HTML formatting styles.
func (*FormattingStyles) Clone ¶
func (is *FormattingStyles) Clone() *FormattingStyles
Clone mimics style inheritance.
type HTMLItem ¶
type HTMLItem struct {
Typ html.NodeType
Data string
Dir Mode
Attributes map[string]string
Styles map[string]string
Children []*HTMLItem
}
HTMLItem is a struct which represents a HTML element or a text node.
type HTMLValues ¶
type HTMLValues struct {
BackgroundColor *color.Color
BorderTopWidth bag.ScaledPoint
BorderRightWidth bag.ScaledPoint
BorderBottomWidth bag.ScaledPoint
BorderLeftWidth bag.ScaledPoint
BorderTopLeftRadius bag.ScaledPoint
BorderTopRightRadius bag.ScaledPoint
BorderBottomLeftRadius bag.ScaledPoint
BorderBottomRightRadius bag.ScaledPoint
BorderTopColor *color.Color
BorderRightColor *color.Color
BorderBottomColor *color.Color
BorderLeftColor *color.Color
BorderTopStyle frontend.BorderStyle
BorderRightStyle frontend.BorderStyle
BorderBottomStyle frontend.BorderStyle
BorderLeftStyle frontend.BorderStyle
MarginTop bag.ScaledPoint
MarginRight bag.ScaledPoint
MarginBottom bag.ScaledPoint
MarginLeft bag.ScaledPoint
PaddingTop bag.ScaledPoint
PaddingRight bag.ScaledPoint
PaddingBottom bag.ScaledPoint
PaddingLeft bag.ScaledPoint
}
HTMLValues contains margin, padding and border values for a rectangular area.
func SettingsToValues ¶
func SettingsToValues(s frontend.TypesettingSettings) HTMLValues
type PageDimensions ¶
type PageDimensions struct {
Width bag.ScaledPoint
Height bag.ScaledPoint
MarginLeft bag.ScaledPoint
MarginRight bag.ScaledPoint
MarginTop bag.ScaledPoint
MarginBottom bag.ScaledPoint
PageAreaLeft bag.ScaledPoint
PageAreaTop bag.ScaledPoint
ContentWidth bag.ScaledPoint
ContentHeight bag.ScaledPoint
// contains filtered or unexported fields
}
PageDimensions contains the page size and the margins of the page.
type StylesStack ¶
type StylesStack []*FormattingStyles
StylesStack mimics CSS style inheritance.
func (StylesStack) CurrentStyle ¶
func (ss StylesStack) CurrentStyle() *FormattingStyles
CurrentStyle returns the current style from the stack. CurrentStyle does not change the stack.
func (*StylesStack) PopStyles ¶
func (ss *StylesStack) PopStyles()
PopStyles removes the top style from the stack.
func (*StylesStack) PushStyles ¶
func (ss *StylesStack) PushStyles() *FormattingStyles
PushStyles creates a new style instance, pushes it onto the stack and returns the new style.
func (*StylesStack) SetDefaultFontFamily ¶
func (ss *StylesStack) SetDefaultFontFamily(ff *frontend.FontFamily)
SetDefaultFontFamily sets the font family that should be used as a default for the document.
func (*StylesStack) SetDefaultFontSize ¶
func (ss *StylesStack) SetDefaultFontSize(size bag.ScaledPoint)
SetDefaultFontSize sets the document font size which should be used for rem calculation.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
fonts
|
|
|
camingocodebold
Package camingocodebold provides the "CamingoCode" font
|
Package camingocodebold provides the "CamingoCode" font |
|
camingocodebolditalic
Package camingocodebolditalic provides the "CamingoCode" font
|
Package camingocodebolditalic provides the "CamingoCode" font |
|
camingocodeitalic
Package camingocodeitalic provides the "CamingoCode" font
|
Package camingocodeitalic provides the "CamingoCode" font |
|
camingocoderegular
Package camingocoderegular provides the "CamingoCode" font
|
Package camingocoderegular provides the "CamingoCode" font |
|
crimsonprobold
Package crimsonprobold provides the "Crimson Pro" font
|
Package crimsonprobold provides the "Crimson Pro" font |
|
crimsonprobolditalic
Package crimsonprobolditalic provides the "Crimson Pro" font
|
Package crimsonprobolditalic provides the "Crimson Pro" font |
|
crimsonproitalic
Package crimsonproitalic provides the "Crimson Pro" font
|
Package crimsonproitalic provides the "Crimson Pro" font |
|
crimsonproregular
Package crimsonproregular provides the "Crimson Pro" font
|
Package crimsonproregular provides the "Crimson Pro" font |
|
texgyreherosbold
Package texgyreherosbold provides the "TeXGyreHeros" font
|
Package texgyreherosbold provides the "TeXGyreHeros" font |
|
texgyreherosbolditalic
Package texgyreherosbolditalic provides the "TeXGyreHeros" font
|
Package texgyreherosbolditalic provides the "TeXGyreHeros" font |
|
texgyreherositalic
Package texgyreherositalic provides the "TeXGyreHeros" font
|
Package texgyreherositalic provides the "TeXGyreHeros" font |
|
texgyreherosregular
Package texgyreherosregular provides the "TeXGyreHeros" font
|
Package texgyreherosregular provides the "TeXGyreHeros" font |