Documentation
¶
Overview ¶
Package css parses the CSS properties supported by the engine.
Index ¶
- Constants
- func ParseColor(s string) (c [4]float64, ok bool)
- func ParsePageFooterStyle(src string) ([]ContentChunk, PageFooterStyle, bool)
- func ParsePageRule(src string) (w, h, margin float64, ok bool)
- type ContentChunk
- type Declarations
- type FontFace
- type PageFooterStyle
- type PageMargins
- type PageMarks
- type PageRule
- type PageSelector
- type PageStyle
- type Rule
Constants ¶
const PxToPt = 0.75
PxToPt converts CSS pixels to PDF points at 96 DPI.
const UAStylesheet = `` /* 500-byte string literal not displayed */
UAStylesheet contains the default styles for HTML elements.
Variables ¶
This section is empty.
Functions ¶
func ParseColor ¶
ParseColor converts a supported CSS color to RGBA components in the range [0,1]. It returns false for invalid values and the transparent keyword. Colors without alpha use 1.
func ParsePageFooterStyle ¶ added in v1.3.2
func ParsePageFooterStyle(src string) ([]ContentChunk, PageFooterStyle, bool)
ParsePageFooterStyle reads the @bottom-center content and supported style.
func ParsePageRule ¶
ParsePageRule reads the first @page rule and returns its width, height, and margin in points. A missing size returns 0,0; a missing margin returns -1. It returns false only when no @page rule exists.
Types ¶
type ContentChunk ¶
ContentChunk is a literal or counter in a page footer's content.
func ParsePageFooter ¶
func ParsePageFooter(src string) ([]ContentChunk, bool)
ParsePageFooter reads @bottom-center content from the first @page rule that defines it.
type Declarations ¶
Declarations contains normalized CSS properties and their values.
func ParseInlineStyle ¶
func ParseInlineStyle(style string) (Declarations, error)
ParseInlineStyle parses inline CSS declarations and ignores invalid ones.
func ParseInlineStyleWithWarnings ¶
func ParseInlineStyleWithWarnings(style string) (Declarations, []string, error)
ParseInlineStyleWithWarnings parses inline declarations and reports those it discards.
type FontFace ¶
FontFace represents an @font-face rule with a family and unresolved src value.
func ParseFontFaces ¶
ParseFontFaces returns @font-face rules in source order.
type PageFooterStyle ¶ added in v1.3.2
type PageFooterStyle struct {
}
PageFooterStyle contains the supported typography and color for @bottom-center.
type PageMargins ¶
type PageMargins struct {
Top, Right, Bottom, Left float64
TopPercent, RightPercent bool
BottomPercent, LeftPercent bool
HasTop, HasRight, HasBottom, HasLeft bool
}
PageMargins stores absolute values in points and percentage values in percent. Presence bits let layout inherit its default for omitted sides.
func (PageMargins) Resolve ¶
func (m PageMargins) Resolve(width, height float64) PageMargins
Resolve converts percentage margins to points using the page-box axes.
type PageMarks ¶
type PageMarks uint8
PageMarks selects printer registration marks from the CSS marks descriptor.
type PageRule ¶
type PageRule struct {
Selector PageSelector
Style PageStyle
Declarations Declarations
MarginBoxes map[string]Declarations
}
PageRule keeps each @page selector and its computed declarations in source order.
func ParsePageRules ¶
ParsePageRules reads all @page rules, retaining selectors and source order.
type PageSelector ¶
PageSelector identifies the named page and optional page pseudo-class.
type PageStyle ¶
type PageStyle struct {
Width, Height float64
HasSize bool
Margins PageMargins
Background [4]float64
HasBackground bool
Rotation int // PDF page rotation in clockwise degrees.
HasRotation bool
Bleed float64
HasBleed bool
Marks PageMarks
HasMarks bool
}
PageStyle is the page-box geometry parsed from one @page rule.
func ParsePageStyle ¶
ParsePageStyle reads page-box size and margins from the first @page rule.
func ResolvePageDefaults ¶
ResolvePageDefaults cascades only unnamed, unqualified @page rules.
type Rule ¶
type Rule struct {
Selector string
Decls Declarations
Order int
}
Rule contains a selector, its declarations, and its order in the stylesheet.
func ParseStylesheet ¶
ParseStylesheet extracts selector rules in source order and ignores at-rules and invalid input.