config

package
v0.0.81 Latest Latest
Warning

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

Go to latest
Published: May 10, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package config contains configuration structures for docpdf.

Index

Constants

This section is empty.

Variables

View Source
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 is a known color.
	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

View Source
var FontStyleBold = FontStyle{/* contains filtered or unexported fields */}

Bold font style (000010)

View Source
var FontStyleItalic = FontStyle{/* contains filtered or unexported fields */}

Italic font style (000001)

View Source
var FontStyleRegular = FontStyle{/* contains filtered or unexported fields */}

Regular font style (000000)

View Source
var FontStyleUnderline = FontStyle{/* contains filtered or unexported fields */}

Underline font style (000011)

Functions

func ColorChannelFromFloat added in v0.0.81

func ColorChannelFromFloat(v float64) uint8

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

func NewCell added in v0.0.81

func NewCell() *Cell

funcion que retorna un nuevo estilo de celda

func (*Cell) Equals added in v0.0.81

func (c *Cell) Equals(other *Cell) bool

metodo para comparar dos estilos de celda

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

func ColorFromAlphaMixedRGBA(r, g, b, a uint32) Color

ColorFromAlphaMixedRGBA returns the system alpha mixed rgba values.

func ColorFromHex added in v0.0.81

func ColorFromHex(hex string) Color

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

func ColorFromKnown(known string) Color

ColorFromKnown returns an internal color from a known (basic) color name.

func ColorFromRGB added in v0.0.81

func ColorFromRGB(rgb string) (output Color)

ColorFromRGB returns a color from an `rgb()` css function.

func ColorFromRGBA added in v0.0.81

func ColorFromRGBA(rgba string) (output Color)

ColorFromRGBA returns a color from an `rgba()` css function.

func ParseColor added in v0.0.81

func ParseColor(rawColor string) Color

ParseColor parses a color from a string.

func (Color) AverageWith added in v0.0.81

func (c Color) AverageWith(other Color) Color

AverageWith averages two colors.

func (Color) Equals added in v0.0.81

func (c Color) Equals(other Color) bool

Equals returns true if the color equals another.

func (Color) IsTransparent added in v0.0.81

func (c Color) IsTransparent() bool

IsTransparent returns if the colors alpha channel is zero.

func (Color) IsZero added in v0.0.81

func (c Color) IsZero() bool

IsZero returns if the color has been set or not.

func (Color) RGBA added in v0.0.81

func (c Color) RGBA() (r, g, b, a uint32)

RGBA returns the color as a pre-alpha mixed color set.

func (Color) String added in v0.0.81

func (c Color) String() string

String returns a css string representation of the color in hexadecimal format (#RRGGBB).

func (Color) WithAlpha added in v0.0.81

func (c Color) WithAlpha(a uint8) Color

WithAlpha returns a copy of the color with a given alpha.

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

func GetCompleteFont(styleStr string, size float64, color Color, family string) FontStyle

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

func GetFontStyle(fontStyleStr string) FontStyle

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

func GetFontStyleInIntFormat(fontStyle string) FontStyle

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

func NewFontStyle(name string, size float64, color ...Color) FontStyle

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) AndNot added in v0.0.80

func (fs FontStyle) AndNot(other FontStyle) FontStyle

Bitwise operations for FontStyle

func (FontStyle) BitwiseAnd added in v0.0.80

func (fs FontStyle) BitwiseAnd(other FontStyle) FontStyle

BitwiseAnd implements the & operator for FontStyle

func (FontStyle) Equals added in v0.0.80

func (fs FontStyle) Equals(other FontStyle) bool

Equals checks if two FontStyle values are equal based on their intStyle

func (FontStyle) GetColor added in v0.0.80

func (fs FontStyle) GetColor() Color

GetColor returns the font color

func (FontStyle) GetFamily added in v0.0.80

func (fs FontStyle) GetFamily() string

GetFamily returns the font family name

func (FontStyle) GetIntStyle added in v0.0.80

func (fs FontStyle) GetIntStyle() int

GetIntStyle returns the integer style value

func (FontStyle) GetName added in v0.0.80

func (fs FontStyle) GetName() string

GetName returns the name of the font style

func (FontStyle) GetSize added in v0.0.80

func (fs FontStyle) GetSize() float64

GetSize returns the font size

func (*FontStyle) SetColor added in v0.0.80

func (fs *FontStyle) SetColor(color Color)

SetColor sets the font color

func (*FontStyle) SetFamily added in v0.0.80

func (fs *FontStyle) SetFamily(family string)

SetFamily sets the font family name

func (*FontStyle) SetIntStyle added in v0.0.80

func (fs *FontStyle) SetIntStyle(intStyle int)

SetIntStyle sets the integer style value

func (*FontStyle) SetName added in v0.0.80

func (fs *FontStyle) SetName(name string)

SetName sets the name of the font style

func (*FontStyle) SetSize added in v0.0.80

func (fs *FontStyle) SetSize(size float64)

SetSize sets the font size

func (FontStyle) WithColor added in v0.0.80

func (fs FontStyle) WithColor(color Color) FontStyle

WithColor returns a copy of this style with the specified color

func (FontStyle) WithSize added in v0.0.80

func (fs FontStyle) WithSize(size float64) FontStyle

WithSize returns a copy of this style with the specified size

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

func (ts TextStyle) GetAlignment() Alignment

GetAlignment returns the text alignment

func (TextStyle) GetFontStyle added in v0.0.80

func (ts TextStyle) GetFontStyle() FontStyle

GetFontStyle returns the FontStyle

func (TextStyle) GetLineSpacing added in v0.0.80

func (ts TextStyle) GetLineSpacing() float64

GetLineSpacing returns the line spacing

func (TextStyle) GetSpaceAfter added in v0.0.80

func (ts TextStyle) GetSpaceAfter() float64

GetSpaceAfter returns the space after the text

func (TextStyle) GetSpaceBefore added in v0.0.80

func (ts TextStyle) GetSpaceBefore() float64

GetSpaceBefore returns the space before the text

func (*TextStyle) SetAlignment added in v0.0.80

func (ts *TextStyle) SetAlignment(alignment Alignment)

SetAlignment sets the text alignment

func (*TextStyle) SetFontStyle added in v0.0.80

func (ts *TextStyle) SetFontStyle(fontStyle FontStyle)

SetFontStyle sets the FontStyle

func (*TextStyle) SetLineSpacing added in v0.0.80

func (ts *TextStyle) SetLineSpacing(lineSpacing float64)

SetLineSpacing sets the line spacing

func (*TextStyle) SetSpaceAfter added in v0.0.80

func (ts *TextStyle) SetSpaceAfter(spaceAfter float64)

SetSpaceAfter sets the space after the text

func (*TextStyle) SetSpaceBefore added in v0.0.80

func (ts *TextStyle) SetSpaceBefore(spaceBefore float64)

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

Jump to

Keyboard shortcuts

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