Documentation ¶
Index ¶
- func New(cfgs ...*entity.Config) core.Maroto
- func NewMetricsDecorator(inner core.Maroto) core.Maroto
- type Maroto
- func (m *Maroto) AddAutoRow(cols ...core.Col) core.Row
- func (m *Maroto) AddPages(pages ...core.Page)
- func (m *Maroto) AddRow(rowHeight float64, cols ...core.Col) core.Row
- func (m *Maroto) AddRows(rows ...core.Row)
- func (m *Maroto) FitlnCurrentPage(heightNewLine float64) bool
- func (m *Maroto) Generate() (core.Document, error)
- func (m *Maroto) GetCurrentConfig() *entity.Config
- func (m *Maroto) GetStructure() *node.Node[core.Structure]
- func (m *Maroto) RegisterFooter(rows ...core.Row) error
- func (m *Maroto) RegisterHeader(rows ...core.Row) error
- type MetricsDecorator
- func (m *MetricsDecorator) AddAutoRow(cols ...core.Col) core.Row
- func (m *MetricsDecorator) AddPages(pages ...core.Page)
- func (m *MetricsDecorator) AddRow(rowHeight float64, cols ...core.Col) core.Row
- func (m *MetricsDecorator) AddRows(rows ...core.Row)
- func (m *MetricsDecorator) FitlnCurrentPage(heightNewLine float64) bool
- func (m *MetricsDecorator) Generate() (core.Document, error)
- func (m *MetricsDecorator) GetCurrentConfig() *entity.Config
- func (m *MetricsDecorator) GetStructure() *node.Node[core.Structure]
- func (m *MetricsDecorator) RegisterFooter(rows ...core.Row) error
- func (m *MetricsDecorator) RegisterHeader(rows ...core.Row) error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New is responsible for create a new instance of core.Maroto. It's optional to provide an *entity.Config with customizations those customization are created by using the config.Builder.
Example ¶
ExampleNew demonstrates how to create a maroto instance.
// optional b := config.NewBuilder() cfg := b.Build() m := maroto.New(cfg) // cfg is an optional // Do things and generate _, _ = m.Generate()
Output:
func NewMetricsDecorator ¶
NewMetricsDecorator is responsible to create the metrics decorator for the maroto instance.
Example ¶
ExampleNewMetricsDecorator demonstrates how to create a maroto metrics decorator instance.
// optional b := config.NewBuilder() cfg := b.Build() mrt := maroto.New(cfg) // cfg is an optional m := maroto.NewMetricsDecorator(mrt) // decorator of maroto // Do things and generate _, _ = m.Generate()
Output:
Types ¶
type Maroto ¶
type Maroto struct {
// contains filtered or unexported fields
}
func (*Maroto) AddAutoRow ¶ added in v2.1.0
AddAutoRow is responsible for adding a line with automatic height to the current document. The row height will be calculated based on its content.
func (*Maroto) AddPages ¶
AddPages is responsible for add pages directly in the document. By adding a page directly, the current cursor will reset and the new page will appear as the next. If the page provided have more rows than the maximum useful area of a page, maroto will split that page in more than one.
Example ¶
ExampleMaroto_AddPages demonstrates how to add a new page in maroto.
m := maroto.New() p := page.New() p.Add(code.NewBarRow(10, "barcode")) m.AddPages(p) // Do things and generate
Output:
func (*Maroto) AddRow ¶
AddRow is responsible for add one row in the current document. By adding a row, if the row will extrapolate the useful area of a page, maroto will automatically add a new page. Maroto use the information of PageSize, PageMargin, FooterSize and HeaderSize to calculate the useful area of a page.
Example ¶
ExampleMaroto_AddRow demonstrates how to add a new row in maroto.
m := maroto.New() m.AddRow(10, text.NewCol(12, "text")) // Do things and generate
Output:
func (*Maroto) AddRows ¶
AddRows is responsible for add rows in the current document. By adding a row, if the row will extrapolate the useful area of a page, maroto will automatically add a new page. Maroto use the information of PageSize, PageMargin, FooterSize and HeaderSize to calculate the useful area of a page.
Example ¶
ExampleMaroto_AddRows demonstrates how to add new rows in maroto.
m := maroto.New() m.AddRows( code.NewBarRow(12, "barcode"), text.NewRow(12, "text"), ) // Do things and generate
Output:
func (*Maroto) FitlnCurrentPage ¶
FitlnCurrentPage is responsible to validating whether a line fits on the current page.
Example ¶
ExampleMaroto_FitlnCurrentPage demonstrate how to check if the new line fits on the current page
m := maroto.New() m.FitlnCurrentPage(12) // Do things and generate
Output:
func (*Maroto) Generate ¶
Generate is responsible to compute the component tree created by the usage of all other Maroto methods, and generate the PDF document.
Example ¶
ExampleMaroto_Generate demonstrates how to generate a file.
m := maroto.New() // Add rows, pages and etc. doc, err := m.Generate() if err != nil { log.Fatal(err) } // You can retrieve as Base64, Save file, Merge with another file or GetReport. _ = doc.GetBytes()
Output:
func (*Maroto) GetCurrentConfig ¶ added in v2.0.5
GetCurrentConfig is responsible for returning the current settings from the file
Example ¶
ExampleMaroto_FitlnCurrentPage demonstrate how to check if the new line fits on the current page
m := maroto.New() m.GetCurrentConfig() // Do things and generate
Output:
func (*Maroto) GetStructure ¶
GetStructure is responsible for return the component tree, this is useful on unit tests cases.
Example ¶
ExampleMarotoGetStruct demonstrates how to get maroto component tree
m := maroto.New() m.AddRow(40, text.NewCol(12, "text")) m.GetStructure() // Do things and generate
Output:
func (*Maroto) RegisterFooter ¶
RegisterFooter is responsible to define a set of rows as a footer of the document. The footer will appear in every new page of the document. The footer cannot occupy an area greater than the useful area of the page, it this case the method will return an error.
func (*Maroto) RegisterHeader ¶
RegisterHeader is responsible to define a set of rows as a header of the document. The header will appear in every new page of the document. The header cannot occupy an area greater than the useful area of the page, it this case the method will return an error.
Example ¶
ExampleMaroto_RegisterHeader demonstrates how to register a header to me added in every new page. An error is returned if the area occupied by the header is greater than the page area.
m := maroto.New() err := m.RegisterHeader( code.NewBarRow(12, "barcode"), text.NewRow(12, "text")) if err != nil { panic(err) } // Do things and generate
Output:
type MetricsDecorator ¶
type MetricsDecorator struct {
// contains filtered or unexported fields
}
func (*MetricsDecorator) AddAutoRow ¶ added in v2.1.0
func (m *MetricsDecorator) AddAutoRow(cols ...core.Col) core.Row
AddRow decorates the AddRow method of maroto instance.
func (*MetricsDecorator) AddPages ¶
func (m *MetricsDecorator) AddPages(pages ...core.Page)
AddPages decorates the AddPages method of maroto instance.
func (*MetricsDecorator) AddRows ¶
func (m *MetricsDecorator) AddRows(rows ...core.Row)
AddRows decorates the AddRows method of maroto instance.
func (*MetricsDecorator) FitlnCurrentPage ¶
func (m *MetricsDecorator) FitlnCurrentPage(heightNewLine float64) bool
FitlnCurrentPage decoratess the FitlnCurrentPage method of maroto instance.
func (*MetricsDecorator) Generate ¶
func (m *MetricsDecorator) Generate() (core.Document, error)
Generate decorates the Generate method of maroto instance.
func (*MetricsDecorator) GetCurrentConfig ¶ added in v2.0.5
func (m *MetricsDecorator) GetCurrentConfig() *entity.Config
GetCurrentConfig decorates the GetCurrentConfig method of maroto instance.
func (*MetricsDecorator) GetStructure ¶
func (m *MetricsDecorator) GetStructure() *node.Node[core.Structure]
GetStructure decorates the GetStructure method of maroto instance.
func (*MetricsDecorator) RegisterFooter ¶
func (m *MetricsDecorator) RegisterFooter(rows ...core.Row) error
RegisterFooter decorates the RegisterFooter method of maroto instance.
func (*MetricsDecorator) RegisterHeader ¶
func (m *MetricsDecorator) RegisterHeader(rows ...core.Row) error
RegisterHeader decorates the RegisterHeader method of maroto instance.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
Package docs is the documentation of maroto lib.
|
Package docs is the documentation of maroto lib. |
internal
|
|
providers/gofpdf/cellwriter
nolint: dupl
|
nolint: dupl |
Package pkg contains the public code of maroto.
|
Package pkg contains the public code of maroto. |
components
Package components contains the public components of maroto.
|
Package components contains the public components of maroto. |
components/code
Package code implements creation of Barcode, MatrixCode and QrCode.
|
Package code implements creation of Barcode, MatrixCode and QrCode. |
components/col
Package col implements creation of columns.
|
Package col implements creation of columns. |
components/image
Package image implements creation of images from file and bytes.
|
Package image implements creation of images from file and bytes. |
components/line
Package line implements creation of lines.
|
Package line implements creation of lines. |
components/list
Package list implements creation of lists (old tablelist).
|
Package list implements creation of lists (old tablelist). |
components/page
Package page implements creation of pages.
|
Package page implements creation of pages. |
components/row
Package row implements creation of rows.
|
Package row implements creation of rows. |
components/signature
Package signature implements creation of signatures.
|
Package signature implements creation of signatures. |
components/text
Package text implements creation of texts.
|
Package text implements creation of texts. |
config
Package config implements custom configuration builder.
|
Package config implements custom configuration builder. |
consts
Package consts contains the public constants of maroto.
|
Package consts contains the public constants of maroto. |
consts/align
Package align contains all align types.
|
Package align contains all align types. |
consts/border
Package border contains all border types.
|
Package border contains all border types. |
consts/breakline
Package breakline contains all break line strategies.
|
Package breakline contains all break line strategies. |
consts/extension
Package extension contains all image extensions.
|
Package extension contains all image extensions. |
consts/fontfamily
Package fontfamily contains all default font families.
|
Package fontfamily contains all default font families. |
consts/fontstyle
Package fontstyle contains all default font styles.
|
Package fontstyle contains all default font styles. |
consts/linestyle
Package linestyle contains all line styles.
|
Package linestyle contains all line styles. |
consts/orientation
Package orientation contains all orientations.
|
Package orientation contains all orientations. |
consts/pagesize
Package pagesize contains all default page sizes.
|
Package pagesize contains all default page sizes. |
consts/protection
Package protection contains all protection types.
|
Package protection contains all protection types. |
consts/provider
Package provider contains all document generation providers.
|
Package provider contains all document generation providers. |
core
Package core contains all core interfaces and basic implementations.
|
Package core contains all core interfaces and basic implementations. |
core/entity
Package entity contains all core entities.
|
Package entity contains all core entities. |
merge
Package merge implements PDF merge.
|
Package merge implements PDF merge. |
metrics
Package metrics contains metrics models, constants and formatting.
|
Package metrics contains metrics models, constants and formatting. |
props
Package props contain the public properties of maroto.
|
Package props contain the public properties of maroto. |
repository
Package repository implements font repository.
|
Package repository implements font repository. |
test
Package test implements unit test feature.
|
Package test implements unit test feature. |