diff --git a/README.md b/README.md index 025e7549..ca04d252 100644 --- a/README.md +++ b/README.md @@ -18,12 +18,12 @@ You can write your PDFs like you are creating a site using Bootstrap. A Row may Besides that, pages will be added when content may extrapolate the useful area. You can define a header which will be added always when a new page appear, in this case, a header may have many rows, lines or tablelist. -#### Maroto `v2.0.0-beta.9` is here! Try out: +#### Maroto `v2.0.0-beta.12` is here! Try out: * Installation with`go get`: ```bash -go get github.com/johnfercher/maroto/v2@v2.0.0-beta.9 +go get github.com/johnfercher/maroto/v2@v2.0.0-beta.12 ``` * You can see the full `v2` documentation [here](https://maroto.io/). diff --git a/docs/README.md b/docs/README.md index 494fc146..a8461e60 100644 --- a/docs/README.md +++ b/docs/README.md @@ -9,12 +9,12 @@ [![Visits Badge](https://badges.pufler.dev/visits/johnfercher/maroto)](https://badges.pufler.dev) [![Stars Badge](https://img.shields.io/github/stars/johnfercher/maroto.svg?style=social&label=Stars)](https://github.com/johnfercher/maroto/stargazers) -#### Maroto`v2.0.0-beta.10`is here! Try out: +#### Maroto`v2.0.0-beta.12`is here! Try out: * Installation with`go get`: ```bash -go get github.com/johnfercher/maroto/v2@v2.0.0-beta.10 +go get github.com/johnfercher/maroto/v2@v2.0.0-beta.12 ``` The public API was completely redesigned with the aim of enhancing the diff --git a/docs/_coverpage.md b/docs/_coverpage.md index 9486a69b..44654354 100644 --- a/docs/_coverpage.md +++ b/docs/_coverpage.md @@ -1,6 +1,6 @@ ![logo](assets/images/logo.png) -# Maroto v2.0.0-beta.10 +# Maroto v2.0.0-beta.12 > An open-source golang lib to create PDFs. Fast and Simple. diff --git a/pkg/components/code/barcode.go b/pkg/components/code/barcode.go index 42e72598..7968b911 100644 --- a/pkg/components/code/barcode.go +++ b/pkg/components/code/barcode.go @@ -1,5 +1,5 @@ -// Package code implements creation of barcode, matrixcode and qrcode. -// nolint:dupl // It's similar to barcode.go and it's hard to extract common code. +// Package code implements creation of Barcode, MatrixCode and QrCode. +// nolint:dupl // It's similar to Barcode.go and it's hard to extract common code. package code import ( @@ -12,7 +12,7 @@ import ( "github.com/johnfercher/maroto/v2/pkg/props" ) -type barcode struct { +type Barcode struct { code string prop props.Barcode config *entity.Config @@ -26,7 +26,7 @@ func NewBar(code string, ps ...props.Barcode) core.Component { } prop.MakeValid() - return &barcode{ + return &Barcode{ code: code, prop: prop, } @@ -46,12 +46,12 @@ func NewBarRow(height float64, code string, ps ...props.Barcode) core.Row { } // Render renders a Barcode into a PDF context. -func (b *barcode) Render(provider core.Provider, cell *entity.Cell) { +func (b *Barcode) Render(provider core.Provider, cell *entity.Cell) { provider.AddBarCode(b.code, cell, &b.prop) } // GetStructure returns the Structure of a Barcode. -func (b *barcode) GetStructure() *node.Node[core.Structure] { +func (b *Barcode) GetStructure() *node.Node[core.Structure] { str := core.Structure{ Type: "barcode", Value: b.code, @@ -62,6 +62,6 @@ func (b *barcode) GetStructure() *node.Node[core.Structure] { } // SetConfig sets the configuration of a Barcode. -func (b *barcode) SetConfig(config *entity.Config) { +func (b *Barcode) SetConfig(config *entity.Config) { b.config = config } diff --git a/pkg/components/code/matrixcode.go b/pkg/components/code/matrixcode.go index 4fe1dd2e..c5f93172 100644 --- a/pkg/components/code/matrixcode.go +++ b/pkg/components/code/matrixcode.go @@ -1,4 +1,4 @@ -// Package code implements creation of barcode, matrixcode and qrcode. +// Package code implements creation of Barcode, MatrixCode and QrCode. // nolint:dupl package code @@ -12,7 +12,7 @@ import ( "github.com/johnfercher/maroto/v2/pkg/props" ) -type matrixCode struct { +type MatrixCode struct { code string prop props.Rect config *entity.Config @@ -26,7 +26,7 @@ func NewMatrix(code string, barcodeProps ...props.Rect) core.Component { } prop.MakeValid() - return &matrixCode{ + return &MatrixCode{ code: code, prop: prop, } @@ -46,12 +46,12 @@ func NewMatrixRow(height float64, code string, ps ...props.Rect) core.Row { } // Render renders a MatrixCode into a PDF context. -func (m *matrixCode) Render(provider core.Provider, cell *entity.Cell) { +func (m *MatrixCode) Render(provider core.Provider, cell *entity.Cell) { provider.AddMatrixCode(m.code, cell, &m.prop) } // GetStructure returns the Structure of a MatrixCode. -func (m *matrixCode) GetStructure() *node.Node[core.Structure] { +func (m *MatrixCode) GetStructure() *node.Node[core.Structure] { str := core.Structure{ Type: "matrixcode", Value: m.code, @@ -62,6 +62,6 @@ func (m *matrixCode) GetStructure() *node.Node[core.Structure] { } // SetConfig sets the configuration of a MatrixCode. -func (m *matrixCode) SetConfig(config *entity.Config) { +func (m *MatrixCode) SetConfig(config *entity.Config) { m.config = config } diff --git a/pkg/components/code/qrcode.go b/pkg/components/code/qrcode.go index 6b2d3fc2..69147221 100644 --- a/pkg/components/code/qrcode.go +++ b/pkg/components/code/qrcode.go @@ -1,4 +1,4 @@ -// Package code implements creation of barcode, matrixcode and qrcode. +// Package code implements creation of Barcode, MatrixCode and QrCode. // nolint:dupl package code @@ -12,7 +12,7 @@ import ( "github.com/johnfercher/maroto/v2/pkg/props" ) -type qrCode struct { +type QrCode struct { code string prop props.Rect config *entity.Config @@ -26,7 +26,7 @@ func NewQr(code string, barcodeProps ...props.Rect) core.Component { } prop.MakeValid() - return &qrCode{ + return &QrCode{ code: code, prop: prop, } @@ -46,12 +46,12 @@ func NewQrRow(height float64, code string, ps ...props.Rect) core.Row { } // Render renders a QrCode into a PDF context. -func (q *qrCode) Render(provider core.Provider, cell *entity.Cell) { +func (q *QrCode) Render(provider core.Provider, cell *entity.Cell) { provider.AddQrCode(q.code, cell, &q.prop) } // GetStructure returns the Structure of a QrCode. -func (q *qrCode) GetStructure() *node.Node[core.Structure] { +func (q *QrCode) GetStructure() *node.Node[core.Structure] { str := core.Structure{ Type: "qrcode", Value: q.code, @@ -62,6 +62,6 @@ func (q *qrCode) GetStructure() *node.Node[core.Structure] { } // SetConfig set the config for the component. -func (q *qrCode) SetConfig(config *entity.Config) { +func (q *QrCode) SetConfig(config *entity.Config) { q.config = config } diff --git a/pkg/components/col/col.go b/pkg/components/col/col.go index 2eb9a0be..8b2614b4 100644 --- a/pkg/components/col/col.go +++ b/pkg/components/col/col.go @@ -9,7 +9,7 @@ import ( "github.com/johnfercher/maroto/v2/pkg/props" ) -type col struct { +type Col struct { size int isMax bool components []core.Component @@ -20,20 +20,20 @@ type col struct { // New is responsible to create an instance of core.Col. func New(size ...int) core.Col { if len(size) == 0 { - return &col{isMax: true} + return &Col{isMax: true} } - return &col{size: size[0]} + return &Col{size: size[0]} } // Add is responsible to add a component to a core.Col. -func (c *col) Add(components ...core.Component) core.Col { +func (c *Col) Add(components ...core.Component) core.Col { c.components = append(c.components, components...) return c } // GetSize returns the size of a core.Col. -func (c *col) GetSize() int { +func (c *Col) GetSize() int { if c.isMax { return c.config.MaxGridSize } @@ -42,7 +42,7 @@ func (c *col) GetSize() int { } // GetStructure returns the Structure of a core.Col. -func (c *col) GetStructure() *node.Node[core.Structure] { +func (c *Col) GetStructure() *node.Node[core.Structure] { str := core.Structure{ Type: "col", Value: c.size, @@ -67,7 +67,7 @@ func (c *col) GetStructure() *node.Node[core.Structure] { } // Render renders a core.Col into a PDF context. -func (c *col) Render(provider core.Provider, cell entity.Cell, createCell bool) { +func (c *Col) Render(provider core.Provider, cell entity.Cell, createCell bool) { if createCell { provider.CreateCol(cell.Width, cell.Height, c.config, c.style) } @@ -78,7 +78,7 @@ func (c *col) Render(provider core.Provider, cell entity.Cell, createCell bool) } // SetConfig set the config for the component. -func (c *col) SetConfig(config *entity.Config) { +func (c *Col) SetConfig(config *entity.Config) { c.config = config for _, component := range c.components { component.SetConfig(config) @@ -86,7 +86,7 @@ func (c *col) SetConfig(config *entity.Config) { } // WithStyle sets the style for the column. -func (c *col) WithStyle(style *props.Cell) core.Col { +func (c *Col) WithStyle(style *props.Cell) core.Col { c.style = style return c } diff --git a/pkg/components/image/bytesimage.go b/pkg/components/image/bytesimage.go index 9453cff4..6a47eeff 100644 --- a/pkg/components/image/bytesimage.go +++ b/pkg/components/image/bytesimage.go @@ -12,7 +12,7 @@ import ( "github.com/johnfercher/maroto/v2/pkg/props" ) -type bytesImage struct { +type BytesImage struct { bytes []byte extension extension.Type prop props.Rect @@ -27,7 +27,7 @@ func NewFromBytes(bytes []byte, extension extension.Type, ps ...props.Rect) core } prop.MakeValid() - return &bytesImage{ + return &BytesImage{ bytes: bytes, prop: prop, extension: extension, @@ -48,12 +48,12 @@ func NewFromBytesRow(height float64, bytes []byte, extension extension.Type, ps } // Render renders an Image into a PDF context. -func (b *bytesImage) Render(provider core.Provider, cell *entity.Cell) { +func (b *BytesImage) Render(provider core.Provider, cell *entity.Cell) { provider.AddImageFromBytes(b.bytes, cell, &b.prop, b.extension) } // GetStructure returns the Structure of an Image. -func (b *bytesImage) GetStructure() *node.Node[core.Structure] { +func (b *BytesImage) GetStructure() *node.Node[core.Structure] { trimLength := 10 if len(b.bytes) < trimLength { trimLength = len(b.bytes) @@ -72,6 +72,6 @@ func (b *bytesImage) GetStructure() *node.Node[core.Structure] { } // SetConfig sets the pdf config. -func (b *bytesImage) SetConfig(config *entity.Config) { +func (b *BytesImage) SetConfig(config *entity.Config) { b.config = config } diff --git a/pkg/components/image/fileimage.go b/pkg/components/image/fileimage.go index 05aa0da2..ed370621 100644 --- a/pkg/components/image/fileimage.go +++ b/pkg/components/image/fileimage.go @@ -11,7 +11,7 @@ import ( "github.com/johnfercher/maroto/v2/pkg/props" ) -type fileImage struct { +type FileImage struct { path string prop props.Rect config *entity.Config @@ -25,7 +25,7 @@ func NewFromFile(path string, ps ...props.Rect) core.Component { } prop.MakeValid() - return &fileImage{ + return &FileImage{ path: path, prop: prop, } @@ -45,12 +45,12 @@ func NewFromFileRow(height float64, path string, ps ...props.Rect) core.Row { } // Render renders an Image into a PDF context. -func (f *fileImage) Render(provider core.Provider, cell *entity.Cell) { +func (f *FileImage) Render(provider core.Provider, cell *entity.Cell) { provider.AddImageFromFile(f.path, cell, &f.prop) } // GetStructure returns the Structure of an Image. -func (f *fileImage) GetStructure() *node.Node[core.Structure] { +func (f *FileImage) GetStructure() *node.Node[core.Structure] { str := core.Structure{ Type: "fileImage", Value: f.path, @@ -61,6 +61,6 @@ func (f *fileImage) GetStructure() *node.Node[core.Structure] { } // SetConfig sets the pdf config. -func (f *fileImage) SetConfig(config *entity.Config) { +func (f *FileImage) SetConfig(config *entity.Config) { f.config = config } diff --git a/pkg/components/line/line.go b/pkg/components/line/line.go index bb05ae07..bcdb5a18 100644 --- a/pkg/components/line/line.go +++ b/pkg/components/line/line.go @@ -11,7 +11,7 @@ import ( "github.com/johnfercher/maroto/v2/pkg/props" ) -type line struct { +type Line struct { config *entity.Config prop props.Line } @@ -24,7 +24,7 @@ func New(ps ...props.Line) core.Component { } lineProp.MakeValid() - return &line{ + return &Line{ prop: lineProp, } } @@ -43,9 +43,9 @@ func NewRow(height float64, ps ...props.Line) core.Row { } // GetStructure returns the Structure of a Line. -func (l *line) GetStructure() *node.Node[core.Structure] { +func (l *Line) GetStructure() *node.Node[core.Structure] { str := core.Structure{ - Type: "lineStyle", + Type: "line", Details: l.prop.ToMap(), } @@ -53,11 +53,11 @@ func (l *line) GetStructure() *node.Node[core.Structure] { } // SetConfig sets the config. -func (l *line) SetConfig(config *entity.Config) { +func (l *Line) SetConfig(config *entity.Config) { l.config = config } // Render renders a Line into a PDF context. -func (l *line) Render(provider core.Provider, cell *entity.Cell) { +func (l *Line) Render(provider core.Provider, cell *entity.Cell) { provider.AddLine(cell, &l.prop) } diff --git a/pkg/components/page/page.go b/pkg/components/page/page.go index 986daabb..27ba5e6e 100644 --- a/pkg/components/page/page.go +++ b/pkg/components/page/page.go @@ -9,7 +9,7 @@ import ( "github.com/johnfercher/maroto/v2/pkg/props" ) -type page struct { +type Page struct { number int total int rows []core.Row @@ -24,13 +24,13 @@ func New(ps ...props.Page) core.Page { prop = ps[0] } - return &page{ + return &Page{ prop: prop, } } // Render renders a Page into a PDF context. -func (p *page) Render(provider core.Provider, cell entity.Cell) { +func (p *Page) Render(provider core.Provider, cell entity.Cell) { innerCell := cell.Copy() prop := &props.Rect{} @@ -50,38 +50,38 @@ func (p *page) Render(provider core.Provider, cell entity.Cell) { } } -// SetConfig sets the page configuration. -func (p *page) SetConfig(config *entity.Config) { +// SetConfig sets the Page configuration. +func (p *Page) SetConfig(config *entity.Config) { p.config = config for _, row := range p.rows { row.SetConfig(config) } } -// SetNumber sets the page number and total. -func (p *page) SetNumber(number int, total int) { +// SetNumber sets the Page number and total. +func (p *Page) SetNumber(number int, total int) { p.number = number p.total = total } -// GetNumber returns the page number. -func (p *page) GetNumber() int { +// GetNumber returns the Page number. +func (p *Page) GetNumber() int { return p.number } -// Add adds one or more rows to the page. -func (p *page) Add(rows ...core.Row) core.Page { +// Add adds one or more rows to the Page. +func (p *Page) Add(rows ...core.Row) core.Page { p.rows = append(p.rows, rows...) return p } -// GetRows returns the rows of the page. -func (p *page) GetRows() []core.Row { +// GetRows returns the rows of the Page. +func (p *Page) GetRows() []core.Row { return p.rows } // GetStructure returns the Structure of a Page. -func (p *page) GetStructure() *node.Node[core.Structure] { +func (p *Page) GetStructure() *node.Node[core.Structure] { str := core.Structure{ Type: "page", } diff --git a/pkg/components/page/page_test.go b/pkg/components/page/page_test.go index f6bb2aed..deabb2e3 100644 --- a/pkg/components/page/page_test.go +++ b/pkg/components/page/page_test.go @@ -14,5 +14,5 @@ func TestNew(t *testing.T) { // Assert assert.NotNil(t, sut) - assert.Equal(t, "*page.page", fmt.Sprintf("%T", sut)) + assert.Equal(t, "*page.Page", fmt.Sprintf("%T", sut)) } diff --git a/pkg/components/row/row.go b/pkg/components/row/row.go index 7e6d575d..be887799 100644 --- a/pkg/components/row/row.go +++ b/pkg/components/row/row.go @@ -10,7 +10,7 @@ import ( "github.com/johnfercher/maroto/v2/pkg/props" ) -type row struct { +type Row struct { height float64 cols []core.Col style *props.Cell @@ -19,13 +19,13 @@ type row struct { // New is responsible to create a core.Row. func New(height float64) core.Row { - return &row{ + return &Row{ height: height, } } -// SetConfig sets the row configuration. -func (r *row) SetConfig(config *entity.Config) { +// SetConfig sets the Row configuration. +func (r *Row) SetConfig(config *entity.Config) { r.config = config for _, cols := range r.cols { cols.SetConfig(config) @@ -33,18 +33,18 @@ func (r *row) SetConfig(config *entity.Config) { } // Add is responsible to add one or more core.Col to a core.Row. -func (r *row) Add(cols ...core.Col) core.Row { +func (r *Row) Add(cols ...core.Col) core.Row { r.cols = append(r.cols, cols...) return r } // GetHeight returns the height of a core.Row. -func (r *row) GetHeight() float64 { +func (r *Row) GetHeight() float64 { return r.height } // GetStructure returns the Structure of a core.Row. -func (r *row) GetStructure() *node.Node[core.Structure] { +func (r *Row) GetStructure() *node.Node[core.Structure] { detailsMap := r.style.ToMap() str := core.Structure{ @@ -64,7 +64,7 @@ func (r *row) GetStructure() *node.Node[core.Structure] { } // Render renders a Row into a PDF context. -func (r *row) Render(provider core.Provider, cell entity.Cell) { +func (r *Row) Render(provider core.Provider, cell entity.Cell) { cell.Height = r.height innerCell := cell.Copy() @@ -89,7 +89,7 @@ func (r *row) Render(provider core.Provider, cell entity.Cell) { } // WithStyle sets the style of a Row. -func (r *row) WithStyle(style *props.Cell) core.Row { +func (r *Row) WithStyle(style *props.Cell) core.Row { r.style = style return r } diff --git a/pkg/components/signature/signature.go b/pkg/components/signature/signature.go index 3f42966a..c989b989 100644 --- a/pkg/components/signature/signature.go +++ b/pkg/components/signature/signature.go @@ -13,7 +13,7 @@ import ( "github.com/johnfercher/maroto/v2/pkg/props" ) -type signature struct { +type Signature struct { value string prop props.Signature config *entity.Config @@ -27,7 +27,7 @@ func New(value string, ps ...props.Signature) core.Component { } prop.MakeValid(fontfamily.Arial) - return &signature{ + return &Signature{ value: value, prop: prop, } @@ -47,7 +47,7 @@ func NewRow(height float64, value string, ps ...props.Signature) core.Row { } // Render renders a Signature into a PDF context. -func (s *signature) Render(provider core.Provider, cell *entity.Cell) { +func (s *Signature) Render(provider core.Provider, cell *entity.Cell) { fontProp := s.prop.ToFontProp() safePadding := 1.5 fontSize := provider.GetTextHeight(fontProp) * safePadding @@ -61,7 +61,7 @@ func (s *signature) Render(provider core.Provider, cell *entity.Cell) { } // GetStructure returns the Structure of a Signature. -func (s *signature) GetStructure() *node.Node[core.Structure] { +func (s *Signature) GetStructure() *node.Node[core.Structure] { str := core.Structure{ Type: "signature", Value: s.value, @@ -72,6 +72,6 @@ func (s *signature) GetStructure() *node.Node[core.Structure] { } // SetConfig sets the config. -func (s *signature) SetConfig(config *entity.Config) { +func (s *Signature) SetConfig(config *entity.Config) { s.config = config } diff --git a/pkg/components/text/text.go b/pkg/components/text/text.go index 02aa8629..9f2956e9 100644 --- a/pkg/components/text/text.go +++ b/pkg/components/text/text.go @@ -11,7 +11,7 @@ import ( "github.com/johnfercher/maroto/v2/pkg/props" ) -type text struct { +type Text struct { value string prop props.Text config *entity.Config @@ -24,7 +24,7 @@ func New(value string, ps ...props.Text) core.Component { textProp = ps[0] } - return &text{ + return &Text{ value: value, prop: textProp, } @@ -44,7 +44,7 @@ func NewRow(height float64, value string, ps ...props.Text) core.Row { } // GetStructure returns the Structure of a Text. -func (t *text) GetStructure() *node.Node[core.Structure] { +func (t *Text) GetStructure() *node.Node[core.Structure] { str := core.Structure{ Type: "text", Value: t.value, @@ -55,12 +55,12 @@ func (t *text) GetStructure() *node.Node[core.Structure] { } // SetConfig sets the config. -func (t *text) SetConfig(config *entity.Config) { +func (t *Text) SetConfig(config *entity.Config) { t.config = config t.prop.MakeValid(t.config.DefaultFont) } // Render renders a Text into a PDF context. -func (t *text) Render(provider core.Provider, cell *entity.Cell) { +func (t *Text) Render(provider core.Provider, cell *entity.Cell) { provider.AddText(t.value, cell, &t.prop) } diff --git a/pkg/config/builder.go b/pkg/config/builder.go index 06bf8c38..f2283a08 100644 --- a/pkg/config/builder.go +++ b/pkg/config/builder.go @@ -42,7 +42,7 @@ type Builder interface { Build() *entity.Config } -type builder struct { +type CfgBuilder struct { providerType provider.Type dimensions *entity.Dimensions margins *entity.Margins @@ -63,7 +63,7 @@ type builder struct { // NewBuilder is responsible to create an instance of Builder. func NewBuilder() Builder { - return &builder{ + return &CfgBuilder{ providerType: provider.Gofpdf, margins: &entity.Margins{ Left: pagesize.DefaultLeftMargin, @@ -83,7 +83,7 @@ func NewBuilder() Builder { } // WithPageSize defines the page size, ex: A4, A4 and etc. -func (b *builder) WithPageSize(size pagesize.Type) Builder { +func (b *CfgBuilder) WithPageSize(size pagesize.Type) Builder { if size == "" { return b } @@ -93,7 +93,7 @@ func (b *builder) WithPageSize(size pagesize.Type) Builder { } // WithDimensions defines custom page dimensions, this overrides page size. -func (b *builder) WithDimensions(width float64, height float64) Builder { +func (b *CfgBuilder) WithDimensions(width float64, height float64) Builder { if width <= 0 || height <= 0 { return b } @@ -107,7 +107,7 @@ func (b *builder) WithDimensions(width float64, height float64) Builder { } // WithMargins defines custom margins, bottom margin is not customizable due to gofpdf limitations. -func (b *builder) WithMargins(left float64, top float64, right float64) Builder { +func (b *CfgBuilder) WithMargins(left float64, top float64, right float64) Builder { if left < pagesize.MinLeftMargin { return b } @@ -128,7 +128,7 @@ func (b *builder) WithMargins(left float64, top float64, right float64) Builder } // WithWorkerPoolSize defines go routine workers, when defined this will execute maroto concurrently. -func (b *builder) WithWorkerPoolSize(poolSize int) Builder { +func (b *CfgBuilder) WithWorkerPoolSize(poolSize int) Builder { if poolSize < 0 { return b } @@ -138,13 +138,13 @@ func (b *builder) WithWorkerPoolSize(poolSize int) Builder { } // WithDebug defines a debug behaviour where maroto will draw borders in everything. -func (b *builder) WithDebug(on bool) Builder { +func (b *CfgBuilder) WithDebug(on bool) Builder { b.debug = on return b } // WithMaxGridSize defines a custom max grid sum which it will change the sum of column sizes. -func (b *builder) WithMaxGridSize(maxGridSize int) Builder { +func (b *CfgBuilder) WithMaxGridSize(maxGridSize int) Builder { if maxGridSize < 0 { return b } @@ -154,7 +154,7 @@ func (b *builder) WithMaxGridSize(maxGridSize int) Builder { } // WithDefaultFont defines a custom font, other than arial. This can be used to define a custom font as default. -func (b *builder) WithDefaultFont(font *props.Font) Builder { +func (b *CfgBuilder) WithDefaultFont(font *props.Font) Builder { if font == nil { return b } @@ -179,7 +179,7 @@ func (b *builder) WithDefaultFont(font *props.Font) Builder { } // WithCustomFonts add custom fonts. -func (b *builder) WithCustomFonts(customFonts []*entity.CustomFont) Builder { +func (b *CfgBuilder) WithCustomFonts(customFonts []*entity.CustomFont) Builder { if customFonts == nil { return b } @@ -189,7 +189,7 @@ func (b *builder) WithCustomFonts(customFonts []*entity.CustomFont) Builder { } // WithPageNumber defines a string pattern to write the current page and total. -func (b *builder) WithPageNumber(pattern string, place props.Place) Builder { +func (b *CfgBuilder) WithPageNumber(pattern string, place props.Place) Builder { if !strings.Contains(pattern, "{current}") && !strings.Contains(pattern, "{total}") { return b } @@ -205,7 +205,7 @@ func (b *builder) WithPageNumber(pattern string, place props.Place) Builder { } // WithProtection defines protection types to the PDF document. -func (b *builder) WithProtection(protectionType protection.Type, userPassword, ownerPassword string) Builder { +func (b *CfgBuilder) WithProtection(protectionType protection.Type, userPassword, ownerPassword string) Builder { b.protection = &entity.Protection{ Type: protectionType, UserPassword: userPassword, @@ -216,20 +216,20 @@ func (b *builder) WithProtection(protectionType protection.Type, userPassword, o } // WithCompression defines compression. -func (b *builder) WithCompression(compression bool) Builder { +func (b *CfgBuilder) WithCompression(compression bool) Builder { b.compression = compression return b } // WithOrientation defines the page orientation. The default orientation is vertical, // if horizontal is defined width and height will be flipped. -func (b *builder) WithOrientation(orientation orientation.Type) Builder { +func (b *CfgBuilder) WithOrientation(orientation orientation.Type) Builder { b.orientation = orientation return b } // WithAuthor defines the author name metadata. -func (b *builder) WithAuthor(author string, isUTF8 bool) Builder { +func (b *CfgBuilder) WithAuthor(author string, isUTF8 bool) Builder { if author == "" { return b } @@ -243,7 +243,7 @@ func (b *builder) WithAuthor(author string, isUTF8 bool) Builder { } // WithCreator defines the creator name metadata. -func (b *builder) WithCreator(creator string, isUTF8 bool) Builder { +func (b *CfgBuilder) WithCreator(creator string, isUTF8 bool) Builder { if creator == "" { return b } @@ -257,7 +257,7 @@ func (b *builder) WithCreator(creator string, isUTF8 bool) Builder { } // WithSubject defines the subject metadata. -func (b *builder) WithSubject(subject string, isUTF8 bool) Builder { +func (b *CfgBuilder) WithSubject(subject string, isUTF8 bool) Builder { if subject == "" { return b } @@ -271,7 +271,7 @@ func (b *builder) WithSubject(subject string, isUTF8 bool) Builder { } // WithTitle defines the title metadata. -func (b *builder) WithTitle(title string, isUTF8 bool) Builder { +func (b *CfgBuilder) WithTitle(title string, isUTF8 bool) Builder { if title == "" { return b } @@ -285,7 +285,7 @@ func (b *builder) WithTitle(title string, isUTF8 bool) Builder { } // WithCreationDate defines the creation date metadata. -func (b *builder) WithCreationDate(time time.Time) Builder { +func (b *CfgBuilder) WithCreationDate(time time.Time) Builder { if time.IsZero() { return b } @@ -296,7 +296,7 @@ func (b *builder) WithCreationDate(time time.Time) Builder { } // WithBackgroundImage defines the background image that will be applied in every page. -func (b *builder) WithBackgroundImage(bytes []byte, ext extension.Type) Builder { +func (b *CfgBuilder) WithBackgroundImage(bytes []byte, ext extension.Type) Builder { b.backgroundImage = &entity.Image{ Bytes: bytes, Extension: ext, @@ -306,7 +306,7 @@ func (b *builder) WithBackgroundImage(bytes []byte, ext extension.Type) Builder } // Build finalizes the customization returning the entity.Config. -func (b *builder) Build() *entity.Config { +func (b *CfgBuilder) Build() *entity.Config { return &entity.Config{ ProviderType: b.providerType, Dimensions: b.getDimensions(), @@ -325,7 +325,7 @@ func (b *builder) Build() *entity.Config { } } -func (b *builder) getDimensions() *entity.Dimensions { +func (b *CfgBuilder) getDimensions() *entity.Dimensions { if b.dimensions != nil { return b.dimensions } diff --git a/pkg/config/builder_test.go b/pkg/config/builder_test.go index 27c390f5..cd77bf42 100644 --- a/pkg/config/builder_test.go +++ b/pkg/config/builder_test.go @@ -22,7 +22,7 @@ func TestNewBuilder(t *testing.T) { // Assert assert.NotNil(t, sut) - assert.Equal(t, "*config.builder", fmt.Sprintf("%T", sut)) + assert.Equal(t, "*config.CfgBuilder", fmt.Sprintf("%T", sut)) } func TestBuilder_Build(t *testing.T) { diff --git a/pkg/repository/repository.go b/pkg/repository/repository.go index 435c5897..79be5eda 100644 --- a/pkg/repository/repository.go +++ b/pkg/repository/repository.go @@ -14,17 +14,17 @@ type Repository interface { Load() ([]*entity.CustomFont, error) } -type repository struct { +type FontRepository struct { customFonts []*entity.CustomFont } // New creates a new repository. func New() Repository { - return &repository{} + return &FontRepository{} } // AddUTF8Font adds a custom font to the repository. -func (r *repository) AddUTF8Font(family string, style fontstyle.Type, file string) Repository { +func (r *FontRepository) AddUTF8Font(family string, style fontstyle.Type, file string) Repository { if family == "" { return r } @@ -47,7 +47,7 @@ func (r *repository) AddUTF8Font(family string, style fontstyle.Type, file strin } // Load loads all custom fonts. -func (r *repository) Load() ([]*entity.CustomFont, error) { +func (r *FontRepository) Load() ([]*entity.CustomFont, error) { for _, customFont := range r.customFonts { bytes, err := os.ReadFile(customFont.File) if err != nil { diff --git a/test/maroto/components/lines/new_line_col_custom_prop.json b/test/maroto/components/lines/new_line_col_custom_prop.json index 86448edf..bd03bc36 100755 --- a/test/maroto/components/lines/new_line_col_custom_prop.json +++ b/test/maroto/components/lines/new_line_col_custom_prop.json @@ -3,7 +3,7 @@ "type": "col", "nodes": [ { - "type": "lineStyle", + "type": "line", "details": { "prop_color": "RGB(100, 50, 200)", "prop_offset_percent": 50, diff --git a/test/maroto/components/lines/new_line_col_default_prop.json b/test/maroto/components/lines/new_line_col_default_prop.json index 00f91b84..11a0a20c 100755 --- a/test/maroto/components/lines/new_line_col_default_prop.json +++ b/test/maroto/components/lines/new_line_col_default_prop.json @@ -3,7 +3,7 @@ "type": "col", "nodes": [ { - "type": "lineStyle", + "type": "line", "details": { "prop_offset_percent": 5, "prop_orientation": "horizontal", diff --git a/test/maroto/components/lines/new_line_custom_prop.json b/test/maroto/components/lines/new_line_custom_prop.json index 6156e6e8..d47127cc 100755 --- a/test/maroto/components/lines/new_line_custom_prop.json +++ b/test/maroto/components/lines/new_line_custom_prop.json @@ -1,5 +1,5 @@ { - "type": "lineStyle", + "type": "line", "details": { "prop_color": "RGB(100, 50, 200)", "prop_offset_percent": 50, diff --git a/test/maroto/components/lines/new_line_default_prop.json b/test/maroto/components/lines/new_line_default_prop.json index 3f6494ec..82f29757 100755 --- a/test/maroto/components/lines/new_line_default_prop.json +++ b/test/maroto/components/lines/new_line_default_prop.json @@ -1,5 +1,5 @@ { - "type": "lineStyle", + "type": "line", "details": { "prop_offset_percent": 5, "prop_orientation": "horizontal", diff --git a/test/maroto/components/lines/new_line_row_custom_prop.json b/test/maroto/components/lines/new_line_row_custom_prop.json index fc2a69f5..5cefe03f 100755 --- a/test/maroto/components/lines/new_line_row_custom_prop.json +++ b/test/maroto/components/lines/new_line_row_custom_prop.json @@ -10,7 +10,7 @@ }, "nodes": [ { - "type": "lineStyle", + "type": "line", "details": { "prop_color": "RGB(100, 50, 200)", "prop_offset_percent": 50, diff --git a/test/maroto/components/lines/new_line_row_default_prop.json b/test/maroto/components/lines/new_line_row_default_prop.json index bfc42e5b..70968b95 100755 --- a/test/maroto/components/lines/new_line_row_default_prop.json +++ b/test/maroto/components/lines/new_line_row_default_prop.json @@ -10,7 +10,7 @@ }, "nodes": [ { - "type": "lineStyle", + "type": "line", "details": { "prop_offset_percent": 5, "prop_orientation": "horizontal", diff --git a/test/maroto/example_unit_test.json b/test/maroto/example_unit_test.json index 4d9ed5fe..c06e579d 100755 --- a/test/maroto/example_unit_test.json +++ b/test/maroto/example_unit_test.json @@ -134,7 +134,7 @@ "type": "col", "nodes": [ { - "type": "lineStyle", + "type": "line", "details": { "prop_offset_percent": 5, "prop_orientation": "horizontal", diff --git a/test/maroto/examples/line.json b/test/maroto/examples/line.json index a0aefaf8..e81b31aa 100755 --- a/test/maroto/examples/line.json +++ b/test/maroto/examples/line.json @@ -27,7 +27,7 @@ "type": "col", "nodes": [ { - "type": "lineStyle", + "type": "line", "details": { "prop_offset_percent": 5, "prop_orientation": "horizontal", @@ -43,7 +43,7 @@ "type": "col", "nodes": [ { - "type": "lineStyle", + "type": "line", "details": { "prop_offset_percent": 5, "prop_orientation": "horizontal", @@ -59,7 +59,7 @@ "type": "col", "nodes": [ { - "type": "lineStyle", + "type": "line", "details": { "prop_offset_percent": 5, "prop_orientation": "horizontal", @@ -81,7 +81,7 @@ "type": "col", "nodes": [ { - "type": "lineStyle", + "type": "line", "details": { "prop_offset_percent": 5, "prop_orientation": "horizontal", @@ -97,7 +97,7 @@ "type": "col", "nodes": [ { - "type": "lineStyle", + "type": "line", "details": { "prop_offset_percent": 5, "prop_orientation": "horizontal", @@ -113,7 +113,7 @@ "type": "col", "nodes": [ { - "type": "lineStyle", + "type": "line", "details": { "prop_offset_percent": 5, "prop_orientation": "horizontal", @@ -135,7 +135,7 @@ "type": "col", "nodes": [ { - "type": "lineStyle", + "type": "line", "details": { "prop_offset_percent": 5, "prop_orientation": "horizontal", @@ -151,7 +151,7 @@ "type": "col", "nodes": [ { - "type": "lineStyle", + "type": "line", "details": { "prop_color": "RGB(255, 0, 0)", "prop_offset_percent": 5, @@ -168,7 +168,7 @@ "type": "col", "nodes": [ { - "type": "lineStyle", + "type": "line", "details": { "prop_offset_percent": 5, "prop_orientation": "vertical", @@ -190,7 +190,7 @@ "type": "col", "nodes": [ { - "type": "lineStyle", + "type": "line", "details": { "prop_offset_percent": 50, "prop_orientation": "horizontal", @@ -206,7 +206,7 @@ "type": "col", "nodes": [ { - "type": "lineStyle", + "type": "line", "details": { "prop_offset_percent": 50, "prop_orientation": "vertical", @@ -222,7 +222,7 @@ "type": "col", "nodes": [ { - "type": "lineStyle", + "type": "line", "details": { "prop_offset_percent": 5, "prop_orientation": "horizontal", @@ -244,7 +244,7 @@ "type": "col", "nodes": [ { - "type": "lineStyle", + "type": "line", "details": { "prop_offset_percent": 5, "prop_orientation": "horizontal", @@ -260,7 +260,7 @@ "type": "col", "nodes": [ { - "type": "lineStyle", + "type": "line", "details": { "prop_color": "RGB(255, 0, 0)", "prop_offset_percent": 70, @@ -277,7 +277,7 @@ "type": "col", "nodes": [ { - "type": "lineStyle", + "type": "line", "details": { "prop_color": "RGB(255, 0, 0)", "prop_offset_percent": 40, diff --git a/test/maroto/examples/simplest.json b/test/maroto/examples/simplest.json index f1702e1c..4712687f 100755 --- a/test/maroto/examples/simplest.json +++ b/test/maroto/examples/simplest.json @@ -139,7 +139,7 @@ "type": "col", "nodes": [ { - "type": "lineStyle", + "type": "line", "details": { "prop_offset_percent": 5, "prop_orientation": "horizontal",