Documentation
¶
Overview ¶
Package config contains configuration structures for docpdf.
Index ¶
- Variables
- func ColorChannelFromFloat(v float64) uint8
- type Alignment
- type Border
- type Cell
- type Color
- type FontFamily
- type FontStyle
- func (fs FontStyle) AndNot(other FontStyle) FontStyle
- func (fs FontStyle) BitwiseAnd(other FontStyle) FontStyle
- func (fs FontStyle) Equals(other FontStyle) bool
- func (fs FontStyle) GetColor() Color
- func (fs FontStyle) GetFamily() string
- func (fs FontStyle) GetIntStyle() int
- func (fs FontStyle) GetName() string
- func (fs FontStyle) GetSize() float64
- func (fs *FontStyle) SetColor(color Color)
- func (fs *FontStyle) SetFamily(family string)
- func (fs *FontStyle) SetIntStyle(intStyle int)
- func (fs *FontStyle) SetName(name string)
- func (fs *FontStyle) SetSize(size float64)
- func (fs FontStyle) WithColor(color Color) FontStyle
- func (fs FontStyle) WithSize(size float64) FontStyle
- type TextStyle
- func (ts TextStyle) GetAlignment() Alignment
- func (ts TextStyle) GetFontStyle() FontStyle
- func (ts TextStyle) GetLineSpacing() float64
- func (ts TextStyle) GetSpaceAfter() float64
- func (ts TextStyle) GetSpaceBefore() float64
- func (ts *TextStyle) SetAlignment(alignment Alignment)
- func (ts *TextStyle) SetFontStyle(fontStyle FontStyle)
- func (ts *TextStyle) SetLineSpacing(lineSpacing float64)
- func (ts *TextStyle) SetSpaceAfter(spaceAfter float64)
- func (ts *TextStyle) SetSpaceBefore(spaceBefore float64)
- type TextStyles
- func (ts *TextStyles) GetChartAxisLabel() TextStyle
- func (ts *TextStyles) GetChartLabel() TextStyle
- func (ts *TextStyles) GetFontFamily() FontFamily
- func (ts *TextStyles) GetFootnote() TextStyle
- func (ts *TextStyles) GetHeader1() TextStyle
- func (ts *TextStyles) GetHeader2() TextStyle
- func (ts *TextStyles) GetHeader3() TextStyle
- func (ts *TextStyles) GetNormal() TextStyle
- func (ts *TextStyles) GetPageFooter() TextStyle
- func (ts *TextStyles) GetPageHeader() TextStyle
- func (ts *TextStyles) LoadFonts(pdf pdfEngine) error
- func (ts *TextStyles) SetChartAxisLabel(style TextStyle)
- func (ts *TextStyles) SetChartLabel(style TextStyle)
- func (ts *TextStyles) SetDefaultTextConfig(pdf pdfEngine)
- func (ts *TextStyles) SetFontFamily(fontFamily FontFamily)
- func (ts *TextStyles) SetFootnote(style TextStyle)
- func (ts *TextStyles) SetHeader1(style TextStyle)
- func (ts *TextStyles) SetHeader2(style TextStyle)
- func (ts *TextStyles) SetHeader3(style TextStyle)
- func (ts *TextStyles) SetNormal(style TextStyle)
- func (ts *TextStyles) SetPageFooter(style TextStyle)
- func (ts *TextStyles) SetPageHeader(style TextStyle)
Constants ¶
This section is empty.
Variables ¶
var ( // ColorTransparent is a fully transparent color. ColorTransparent = Color{R: 255, G: 255, B: 255, A: 0} // ColorWhite is white. ColorWhite = Color{R: 255, G: 255, B: 255, A: 255} // ColorBlack is black. ColorBlack = Color{R: 0, G: 0, B: 0, A: 255} // ColorRed is red. ColorRed = Color{R: 255, G: 0, B: 0, A: 255} // ColorGreen is green. ColorGreen = Color{R: 0, G: 128, B: 0, A: 255} // ColorBlue is blue. ColorBlue = Color{R: 0, G: 0, B: 255, A: 255} // ColorSilver is a known color. ColorSilver = Color{R: 192, G: 192, B: 192, A: 255} // ColorMaroon is a known color. ColorMaroon = Color{R: 128, G: 0, B: 0, A: 255} // ColorPurple is a known color. ColorPurple = Color{R: 128, G: 0, B: 128, A: 255} // ColorFuchsia is a known color. ColorFuchsia = Color{R: 255, G: 0, B: 255, A: 255} // ColorLime is a known color. ColorLime = Color{R: 0, G: 255, B: 0, A: 255} // ColorOlive is a known color. ColorOlive = Color{R: 128, G: 128, B: 0, A: 255} // ColorYellow is a known color. ColorYellow = Color{R: 255, G: 255, B: 0, A: 255} ColorNavy = Color{R: 0, G: 0, B: 128, A: 255} // ColorTeal is a known color. ColorTeal = Color{R: 0, G: 128, B: 128, A: 255} // ColorAqua is a known color. ColorAqua = Color{R: 0, G: 255, B: 255, A: 255} )
Basic Colors from: https://www.w3.org/wiki/CSS/Properties/color/keywords
var FontStyleBold = FontStyle{/* contains filtered or unexported fields */}
Bold font style (000010)
var FontStyleItalic = FontStyle{/* contains filtered or unexported fields */}
Italic font style (000001)
var FontStyleRegular = FontStyle{/* contains filtered or unexported fields */}
Regular font style (000000)
var FontStyleUnderline = FontStyle{/* contains filtered or unexported fields */}
Underline font style (000011)
Functions ¶
func ColorChannelFromFloat ¶ added in v0.0.81
ColorChannelFromFloat returns a normalized byte from a given float value.
Types ¶
type Alignment ¶
type Alignment int
position representa una posición o alineación en el documento
const ( // Left representa alineación a la izquierda Left Alignment = 8 //001000 // Top representa alineación superior Top Alignment = 4 //000100 // Right representa alineación a la derecha Right Alignment = 2 //000010 // Bottom representa alineación inferior Bottom Alignment = 1 //000001 // Center representa alineación al centro Center Alignment = 16 //010000 // Middle representa alineación al medio Middle Alignment = 32 //100000 // Justify representa texto justificado Justify Alignment = 64 //1000000 // AllBorders representa todos los bordes AllBorders Alignment = 15 //001111 )
type Border ¶ added in v0.0.81
type Border struct {
Top bool // Whether to draw the top border
Left bool // Whether to draw the left border
Right bool // Whether to draw the right border
Bottom bool // Whether to draw the bottom border
Width float64 // Width of the border line
Color Color // Color of the border
}
Defines the border style for a cell or table
type Cell ¶ added in v0.0.81
type Cell struct {
Border Border // Border style for the cell
FillColor Color // Background color of the cell
TextColor Color // Color of the text in the cell
Font string // Font name for the cell text
FontSize float64 // Font size for the cell text
}
Defines the style for a cell, including border, fill, text, and font properties
type Color ¶ added in v0.0.81
type Color struct {
R, G, B, A uint8
}
Color is our internal color type because config.Color is bullshit.
func ColorFromAlphaMixedRGBA ¶ added in v0.0.81
ColorFromAlphaMixedRGBA returns the system alpha mixed rgba values.
func ColorFromHex ¶ added in v0.0.81
ColorFromHex returns a color from a css hex code.
NOTE: it will trim a leading '#' character if present.
func ColorFromKnown ¶ added in v0.0.81
ColorFromKnown returns an internal color from a known (basic) color name.
func ColorFromRGB ¶ added in v0.0.81
ColorFromRGB returns a color from an `rgb()` css function.
func ColorFromRGBA ¶ added in v0.0.81
ColorFromRGBA returns a color from an `rgba()` css function.
func ParseColor ¶ added in v0.0.81
ParseColor parses a color from a string.
func (Color) AverageWith ¶ added in v0.0.81
AverageWith averages two colors.
func (Color) IsTransparent ¶ added in v0.0.81
IsTransparent returns if the colors alpha channel is zero.
type FontFamily ¶
type FontFamily struct {
// Regular specifies the filename for the regular font style.
// It's recommended to name this file "regular.ttf".
Regular string
// Bold specifies the filename for the bold font style.
// It's recommended to name this file "bold.ttf".
Bold string
// Italic specifies the filename for the italic font style.
// It's recommended to name this file "italic.ttf".
Italic string
// Underline specifies the filename for the underline font style.
// It's recommended to name this file "underline.ttf".
Underline string
// Path specifies the base directory where the font files are located.
// Defaults to "fonts/".
Path string // Base path for fonts defaults to "fonts/"
}
FontFamily represents font files for different styles It contains the regular, bold, italic, and other styles.
type FontStyle ¶ added in v0.0.80
type FontStyle struct {
// contains filtered or unexported fields
}
FontStyle represents a complete font configuration with styling, size, color, and family This is the unified font structure for the entire docpdf project
func GetCompleteFont ¶ added in v0.0.80
GetCompleteFont creates a FontStyle with all properties specified Use this to create a complete font definition with style, size, color and family
func GetFontStyle ¶ added in v0.0.80
GetFontStyle converts a string font style to its FontStyle representation eg: "B" => FontStyleBold, "I" => FontStyleItalic, "U" => FontStyleUnderline defaults to FontStyleRegular if no valid style is found
func GetFontStyleInIntFormat ¶
GetFontStyleInIntFormat converts a string font style to its integer representation Kept for backward compatibility, but uses the new FontStyle struct internally eg: "B" => FontStyleBold, "I" => FontStyleItalic, "U" => FontStyleUnderline defaults to FontStyleRegular if no valid style is found
func NewFontStyle ¶ added in v0.0.80
NewFontStyle creates a new FontStyle with the given properties name: The font style name (e.g., "regular", "bold", "italic", "underline") size: Font size in points color: Optional color parameter. If not provided, defaults to black (0,0,0,255)
func (FontStyle) BitwiseAnd ¶ added in v0.0.80
BitwiseAnd implements the & operator for FontStyle
func (FontStyle) Equals ¶ added in v0.0.80
Equals checks if two FontStyle values are equal based on their intStyle
func (FontStyle) GetIntStyle ¶ added in v0.0.80
GetIntStyle returns the integer style value
func (*FontStyle) SetIntStyle ¶ added in v0.0.80
SetIntStyle sets the integer style value
type TextStyle ¶
type TextStyle struct {
// contains filtered or unexported fields
}
TextStyle defines the style configuration for different text sections
func NewTextStyle ¶ added in v0.0.80
func NewTextStyle(fontStyle FontStyle, lineSpacing float64, alignment Alignment, spaceBefore, spaceAfter float64) TextStyle
NewTextStyle creates a new TextStyle with all properties
func (TextStyle) GetAlignment ¶ added in v0.0.80
GetAlignment returns the text alignment
func (TextStyle) GetFontStyle ¶ added in v0.0.80
GetFontStyle returns the FontStyle
func (TextStyle) GetLineSpacing ¶ added in v0.0.80
GetLineSpacing returns the line spacing
func (TextStyle) GetSpaceAfter ¶ added in v0.0.80
GetSpaceAfter returns the space after the text
func (TextStyle) GetSpaceBefore ¶ added in v0.0.80
GetSpaceBefore returns the space before the text
func (*TextStyle) SetAlignment ¶ added in v0.0.80
SetAlignment sets the text alignment
func (*TextStyle) SetFontStyle ¶ added in v0.0.80
SetFontStyle sets the FontStyle
func (*TextStyle) SetLineSpacing ¶ added in v0.0.80
SetLineSpacing sets the line spacing
func (*TextStyle) SetSpaceAfter ¶ added in v0.0.80
SetSpaceAfter sets the space after the text
func (*TextStyle) SetSpaceBefore ¶ added in v0.0.80
SetSpaceBefore sets the space before the text
type TextStyles ¶
type TextStyles struct {
// contains filtered or unexported fields
}
TextStyles represents different font configurations for document sections. This was previously named FontConfig in docFont.go.
func DefaultTextConfig ¶ added in v0.0.79
func DefaultTextConfig() TextStyles
DefaultTextStyles returns word-processor like defaults
func (*TextStyles) GetChartAxisLabel ¶ added in v0.0.79
func (ts *TextStyles) GetChartAxisLabel() TextStyle
GetChartAxisLabel returns the chart axis label text style
func (*TextStyles) GetChartLabel ¶ added in v0.0.79
func (ts *TextStyles) GetChartLabel() TextStyle
GetChartLabel returns the chart label text style
func (*TextStyles) GetFontFamily ¶ added in v0.0.79
func (ts *TextStyles) GetFontFamily() FontFamily
GetFontFamily returns the font family configuration
func (*TextStyles) GetFootnote ¶ added in v0.0.79
func (ts *TextStyles) GetFootnote() TextStyle
GetFootnote returns the footnote text style
func (*TextStyles) GetHeader1 ¶ added in v0.0.79
func (ts *TextStyles) GetHeader1() TextStyle
GetHeader1 returns the header1 text style
func (*TextStyles) GetHeader2 ¶ added in v0.0.79
func (ts *TextStyles) GetHeader2() TextStyle
GetHeader2 returns the header2 text style
func (*TextStyles) GetHeader3 ¶ added in v0.0.79
func (ts *TextStyles) GetHeader3() TextStyle
GetHeader3 returns the header3 text style
func (*TextStyles) GetNormal ¶ added in v0.0.79
func (ts *TextStyles) GetNormal() TextStyle
GetNormal returns the normal text style
func (*TextStyles) GetPageFooter ¶ added in v0.0.79
func (ts *TextStyles) GetPageFooter() TextStyle
GetPageFooter returns the page footer text style
func (*TextStyles) GetPageHeader ¶ added in v0.0.79
func (ts *TextStyles) GetPageHeader() TextStyle
GetPageHeader returns the page header text style
func (*TextStyles) LoadFonts ¶ added in v0.0.79
func (ts *TextStyles) LoadFonts(pdf pdfEngine) error
LoadFonts prepares and loads the font family using the provided engine. This method centralizes font loading logic within TextStyles.
func (*TextStyles) SetChartAxisLabel ¶ added in v0.0.79
func (ts *TextStyles) SetChartAxisLabel(style TextStyle)
SetChartAxisLabel sets the chart axis label text style
func (*TextStyles) SetChartLabel ¶ added in v0.0.79
func (ts *TextStyles) SetChartLabel(style TextStyle)
SetChartLabel sets the chart label text style
func (*TextStyles) SetDefaultTextConfig ¶ added in v0.0.79
func (ts *TextStyles) SetDefaultTextConfig(pdf pdfEngine)
SetDefaultTextConfig applies the normal text style
func (*TextStyles) SetFontFamily ¶ added in v0.0.79
func (ts *TextStyles) SetFontFamily(fontFamily FontFamily)
SetFontFamily sets the font family configuration
func (*TextStyles) SetFootnote ¶ added in v0.0.79
func (ts *TextStyles) SetFootnote(style TextStyle)
SetFootnote sets the footnote text style
func (*TextStyles) SetHeader1 ¶ added in v0.0.79
func (ts *TextStyles) SetHeader1(style TextStyle)
SetHeader1 sets the header1 text style
func (*TextStyles) SetHeader2 ¶ added in v0.0.79
func (ts *TextStyles) SetHeader2(style TextStyle)
SetHeader2 sets the header2 text style
func (*TextStyles) SetHeader3 ¶ added in v0.0.79
func (ts *TextStyles) SetHeader3(style TextStyle)
SetHeader3 sets the header3 text style
func (*TextStyles) SetNormal ¶ added in v0.0.79
func (ts *TextStyles) SetNormal(style TextStyle)
SetNormal sets the normal text style
func (*TextStyles) SetPageFooter ¶ added in v0.0.79
func (ts *TextStyles) SetPageFooter(style TextStyle)
SetPageFooter sets the page footer text style
func (*TextStyles) SetPageHeader ¶ added in v0.0.79
func (ts *TextStyles) SetPageHeader(style TextStyle)
SetPageHeader sets the page header text style