props

package
v2.4.2 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2025 License: MIT Imports: 9 Imported by: 1 module, 1 package

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

Overview

Package props contain the public properties of maroto.

Package props contains all props used to customize components.

Index

Constants

This section is empty.

Variables

View Source
var (
	// WhiteColor is a Color with all values in 255.
	WhiteColor = Color{Red: 255, Green: 255, Blue: 255}
	// BlackColor is a Color with all values in 0.
	BlackColor = Color{Red: 0, Green: 0, Blue: 0}
	// RedColor is a Color with only Red in 255.
	RedColor = Color{Red: 255, Green: 0, Blue: 0}
	// GreenColor is a Color with only Green in 255.
	GreenColor = Color{Red: 0, Green: 255, Blue: 0}
	// BlueColor is a Color with only Blue in 255.
	BlueColor = Color{Red: 0, Green: 0, Blue: 255}
)

Functions

This section is empty.

Types

type Barcode

type Barcode struct {
	// Left is the space between the left cell boundary to the barcode, if center is false.
	Left float64
	// Top is space between the upper cell limit to the barcode, if center is false.
	Top float64
	// Percent is how much the barcode will occupy the cell,
	// ex 100%: The barcode will fulfill the entire cell
	// ex 50%: The greater side from the barcode will have half the size of the cell.
	Percent float64
	// Proportion is the proportion between size of the barcode.
	// Ex: 16x9, 4x3...
	Proportion Proportion
	// Center define that the barcode will be vertically and horizontally centralized.
	Center bool
	// Type represents the barcode type. Default: code128
	Type barcode.Type
}

Barcode represents properties from a barcode inside a cell.

func (*Barcode) MakeValid

func (b *Barcode) MakeValid()

MakeValid from Barcode will make the properties from a barcode reliable to fit inside a cell and define default values for a barcode.

func (*Barcode) ToMap

func (b *Barcode) ToMap() map[string]interface{}

ToMap from Barcode will return a map representation from Barcode.

func (*Barcode) ToRectProp

func (b *Barcode) ToRectProp() *Rect

ToRectProp from Barcode will return a Rect representation from Barcode.

type Cell

type Cell struct {
	// BackgroundColor defines which color will be applied to a cell.
	// Default: nil
	BackgroundColor *Color
	// BorderColor defines which color will be applied to a border cell
	// Default: nil
	BorderColor *Color
	// BorderType defines which kind of border will be applied to a cell.
	// Default: border.None
	BorderType border.Type
	// BorderThickness defines the border thickness applied to a cell.
	// Default: 0.2
	BorderThickness float64
	// LineStyle defines which line style will be applied to a cell.
	// Default: Solid
	LineStyle linestyle.Type
}

Cell is the representation of a cell in the grid system. This can be applied to Col or Row

func (*Cell) ToMap

func (c *Cell) ToMap() map[string]interface{}

ToMap adds the Cell fields to the map.

type Color

type Color struct {
	// Red is the amount of red
	Red int
	// Green is the amount of red
	Green int
	// Blue is the amount of red
	Blue int
}

Color represents a color in the RGB (Red, Green, Blue) space, is possible mix values, when all values are 0 the result color is black when all values are 255 the result color is white.

func (*Color) ToString

func (c *Color) ToString() string

ToString returns a string representation of the Color.

type Font

type Font struct {
	// Family of the text, ex: constf.Arial, helvetica and etc.
	Family string
	// Style of the text, ex: constf.Normal, bold and etc.
	Style fontstyle.Type
	// Size of the text.
	Size float64
	// Color define the font color.
	Color *Color
}

Font represents properties from a text.

func (*Font) AppendMap

func (f *Font) AppendMap(m map[string]interface{}) map[string]interface{}

AppendMap appends the font fields to a map.

func (*Font) MakeValid

func (f *Font) MakeValid(defaultFamily string)

MakeValid from Font define default values for a Signature.

func (*Font) ToTextProp

func (f *Font) ToTextProp(align align.Type, top float64, verticalPadding float64) *Text

ToTextProp from Font return a Text based on Font.

type Line

type Line struct {
	// Color define the line color.
	Color *Color
	// Style define the line style (solid or dashed).
	Style linestyle.Type
	// Thickness define the line thicknesl.
	Thickness float64
	// Orientation define if line would be horizontal or vertical.
	Orientation orientation.Type
	// OffsetPercent define where the line would be placed, 0 is the start of cell, 50 the middle and 100 the end.
	OffsetPercent float64
	// SizePercent define the size of the line inside cell.
	SizePercent float64
}

Line represents properties from a Line inside a cell.

func (*Line) MakeValid

func (l *Line) MakeValid()

MakeValid from Line define default values for a Line.

func (*Line) ToMap

func (l *Line) ToMap() map[string]interface{}

ToMap returns a map with the Line fields.

type PageNumber

type PageNumber struct {
	// Pattern is the string pattern which will be used to apply the page count component.
	Pattern string
	// Place defines where the page count component will be placed.
	Place Place
	// Family defines which font family will be applied to page count.
	Family string
	// Style defines which font style will be applied to page count.
	Style fontstyle.Type
	// Size defines which font size will be applied to page count.
	Size float64
	// Color defines which will be applied to page count.
	Color *Color
}

PageNumber have attributes of page number

func (*PageNumber) AppendMap

func (p *PageNumber) AppendMap(m map[string]interface{}) map[string]interface{}

AppendMap appends the font fields to a map.

func (*PageNumber) GetNumberTextProp

func (p *PageNumber) GetNumberTextProp(height float64) *Text

GetNumberTextProp returns the Text properties of the page number.

func (*PageNumber) GetPageString

func (p *PageNumber) GetPageString(current, total int) string

GetPageString returns the page string.

func (*PageNumber) WithFont

func (p *PageNumber) WithFont(font *Font)

WithFont apply font if not defined before.

type Place

type Place string

Place is the representation of a place in a page.

const (
	// LeftTop is the place in the left top of the page.
	LeftTop Place = "left_top"
	// Top is the place in the top of the page.
	Top Place = "top"
	// RightTop is the place in the right top of the page.
	RightTop Place = "right_top"
	// LeftBottom is the place in the left bottom of the page.
	LeftBottom Place = "left_bottom"
	// Bottom is the place in the bottom of the page.
	Bottom Place = "bottom"
	// RightBottom is the place in the right bottom of the page.
	RightBottom Place = "right_bottom"
)

func (Place) IsValid

func (p Place) IsValid() bool

IsValid checks if the place is valid.

type Proportion

type Proportion struct {
	// Width from the rectangle: Barcode, image and etc.
	Width float64
	// Height from the rectangle: Barcode, image and etc.
	Height float64
}

Proportion represents a proportion from a rectangle, example: 16x9, 4x3...

type Rect

type Rect struct {
	// Left is the space between the left cell boundary to the rectangle, if center is false.
	Left float64
	// Top is space between the upper cell limit to the barcode, if center is false.
	Top float64
	// Percent is how much the rectangle will occupy the cell,
	// ex 100%: The rectangle will fulfill the entire cell
	// ex 50%: The greater side from the rectangle will have half the size of the cell.
	Percent float64
	// indicate whether only the width should be used as a reference to calculate the component size, disregarding the height
	// ex true: The component will be scaled only based on the available width, disregarding the available height
	JustReferenceWidth bool
	// Center define that the barcode will be vertically and horizontally centralized.
	Center bool
}

Rect represents properties from a rectangle (Image, QrCode or Barcode) inside a cell.

func (*Rect) MakeValid

func (r *Rect) MakeValid()

MakeValid from Rect will make the properties from a rectangle reliable to fit inside a cell and define default values for a rectangle.

func (*Rect) ToMap

func (r *Rect) ToMap() map[string]interface{}

ToMap from Rect will return a map representation from Rect.

type Signature

type Signature struct {
	// FontFamily of the text, ex: consts.Arial, helvetica and etc.
	FontFamily string
	// FontStyle of the text, ex: consts.Normal, bold and etc.
	FontStyle fontstyle.Type
	// FontSize of the text.
	FontSize float64
	// FontColor define the font color.
	FontColor *Color
	// LineColor define the line color.
	LineColor *Color
	// LineStyle define the line style (solid or dashed).
	LineStyle linestyle.Type
	// LineThickness define the line thickness.
	LineThickness float64

	SafePadding float64
}

Signature represents properties from a signature.

func (*Signature) MakeValid

func (s *Signature) MakeValid(defaultFontFamily string)

MakeValid from Signature define default values for a Signature.

func (*Signature) ToFontProp

func (s *Signature) ToFontProp() *Font

ToFontProp from Signature return a Font based on Signature.

func (*Signature) ToLineProp

func (s *Signature) ToLineProp(offsetPercent float64) *Line

ToLineProp from Signature return a Line based on Signature.

func (*Signature) ToMap

func (s *Signature) ToMap() map[string]interface{}

ToMap returns a map with the Signature fields.

func (*Signature) ToTextProp

func (s *Signature) ToTextProp(align align.Type, top float64, verticalPadding float64) *Text

ToTextProp from Signature return a Text based on Signature.

type Text

type Text struct {
	// Top is the amount of space between the upper cell limit and the text.
	Top float64
	// Bottom is the amount of space between the lower cell limit and the text. (Used by auto row only)
	Bottom float64
	// Left is the minimal amount of space between the left cell boundary and the text.
	Left float64
	// Right is the minimal amount of space between the right cell boundary and the text.
	Right float64
	// Family of the text, ex: consts.Arial, helvetica and etc.
	Family string
	// Style of the text, ex: consts.Normal, bold and etc.
	Style fontstyle.Type
	// Size of the text.
	Size float64
	// Align of the text.
	Align align.Type
	// BreakLineStrategy define the break line strategy.
	BreakLineStrategy breakline.Strategy
	// VerticalPadding define an additional space between linet.
	VerticalPadding float64
	// Color define the font style color.
	Color *Color
	// Hyperlink define a link to be opened when the text is clicked.
	Hyperlink *string
}

Text represents properties from a Text inside a cell.

func (*Text) MakeValid

func (t *Text) MakeValid(font *Font)

MakeValid from Text define default values for a Text.

func (*Text) ToMap

func (t *Text) ToMap() map[string]interface{}

ToMap converts a Text to a map.

Jump to

Keyboard shortcuts

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