Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

features/Doc processor #504

Draft
wants to merge 117 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
8a8d5d6
feature: configure pdf processor framework
Fernando-hub527 Sep 26, 2024
9987468
feature: implement an in-memory repository
Fernando-hub527 Sep 26, 2024
6946142
feature: Implement json deserializer
Fernando-hub527 Sep 27, 2024
bbd2f4f
feature: Add components that will be received in the template
Fernando-hub527 Sep 27, 2024
97f3ce7
feature: Add components that will be received in the template
Fernando-hub527 Sep 29, 2024
f8ffc58
fix: update json deserializer to use new pdf struct
Fernando-hub527 Sep 29, 2024
c10f608
feat: implement content deserialization
Fernando-hub527 Sep 29, 2024
9f7c16f
feature: Generate PDF components
Fernando-hub527 Sep 29, 2024
9ae04f9
feature: set provider to generate pdf
Fernando-hub527 Oct 4, 2024
93a6e43
refactory: allow the definition of a list of templates
Fernando-hub527 Oct 6, 2024
7d77c89
test: validate Builder deserialization
Fernando-hub527 Oct 9, 2024
079b38e
feat: Add build props deserialization
Fernando-hub527 Oct 9, 2024
ed17cdb
fix: generate valid build structure
Fernando-hub527 Oct 9, 2024
817e9cb
feat: provide an abstract factory to create mapper components
Fernando-hub527 Oct 10, 2024
ca8ec92
test: validate document creation
Fernando-hub527 Oct 10, 2024
ee2e56d
fix: fix error in document creation
Fernando-hub527 Oct 10, 2024
17038fd
test: fix bug in mock creation
Fernando-hub527 Oct 11, 2024
d3882f4
test: validate page mapper creation
Fernando-hub527 Oct 11, 2024
5250a37
feat: Configure mapper page creation
Fernando-hub527 Oct 11, 2024
8ca8f15
test: validate list creation
Fernando-hub527 Oct 12, 2024
7e5d153
feat: Implement component list creation
Fernando-hub527 Oct 12, 2024
cf04731
test: validate row creation
Fernando-hub527 Oct 13, 2024
9fc1e95
feat: Implement component row creation
Fernando-hub527 Oct 13, 2024
4ffab23
feat: create component mappers
Fernando-hub527 Oct 13, 2024
2645fb1
test: valid col creation
Fernando-hub527 Oct 13, 2024
4d75347
feat: Implement component col creation
Fernando-hub527 Oct 13, 2024
db71615
feat: create component property mapper
Fernando-hub527 Oct 16, 2024
e0068d5
test: validate barcode component creation
Fernando-hub527 Oct 22, 2024
f76f263
feat: create barcode from map
Fernando-hub527 Oct 22, 2024
ebca07e
test: validate matrixcode component creation
Fernando-hub527 Oct 23, 2024
65b0170
feat: create matrixcode from map
Fernando-hub527 Oct 23, 2024
ddedb1e
test: validate qrcode component creation
Fernando-hub527 Oct 23, 2024
f0f2e43
feat: create qrcode from map
Fernando-hub527 Oct 23, 2024
e355c2f
test: validate line component creation
Fernando-hub527 Oct 23, 2024
51cd965
feat: create line from map
Fernando-hub527 Oct 23, 2024
c2da801
refactor: update parameter name
Fernando-hub527 Oct 23, 2024
c34333e
test: validate line component creation
Fernando-hub527 Oct 23, 2024
2a2c65f
feat: create signature from map
Fernando-hub527 Oct 23, 2024
42108d6
test: validate text component creation
Fernando-hub527 Oct 23, 2024
0568532
feat: create text from map
Fernando-hub527 Oct 23, 2024
5bfc846
feature/repository-loader (#490)
zjom Oct 25, 2024
359336e
style: fix errors reported by lint
Fernando-hub527 Oct 25, 2024
3712af8
docs: document methods and functions
Fernando-hub527 Oct 26, 2024
168a943
test: validate image component creation
Fernando-hub527 Oct 27, 2024
e5a596e
feat: create image from map
Fernando-hub527 Oct 27, 2024
a59e9ac
test:validate barcode component creation
Fernando-hub527 Oct 27, 2024
bf18848
feat: create barcode component
Fernando-hub527 Oct 27, 2024
186664f
test: validate creation of matrixcode component
Fernando-hub527 Oct 27, 2024
859d6f2
feat: matrixcode component creation
Fernando-hub527 Oct 27, 2024
040828c
test: validate the creation of the qrcode
Fernando-hub527 Oct 31, 2024
814f134
feat: create qrcode component
Fernando-hub527 Oct 31, 2024
87ba0a0
test: validate image creation
Fernando-hub527 Oct 31, 2024
fe56a3d
feat: create image component
Fernando-hub527 Oct 31, 2024
321e55e
test: validate line creation
Fernando-hub527 Oct 31, 2024
dd53701
feat: create line component
Fernando-hub527 Oct 31, 2024
a3e75d8
test: validate creation of signature component
Fernando-hub527 Nov 2, 2024
6700936
feat: create signature component
Fernando-hub527 Nov 2, 2024
b6e88d8
test: validate creation of text component
Fernando-hub527 Nov 2, 2024
b7a1fc8
feat: create text component
Fernando-hub527 Nov 2, 2024
6587e54
refactor: Update interfaces
Fernando-hub527 Nov 5, 2024
b66d83e
test: validate row creation
Fernando-hub527 Nov 5, 2024
f041d5c
feat: create row component
Fernando-hub527 Nov 5, 2024
6613097
test: validate page creation
Fernando-hub527 Nov 5, 2024
bcd5a45
feat: create page component
Fernando-hub527 Nov 5, 2024
42c6f58
test: validate col creation
Fernando-hub527 Nov 5, 2024
103eb47
feat: create col component
Fernando-hub527 Nov 5, 2024
9471b89
test: Validate component list creation
Fernando-hub527 Nov 5, 2024
cc099dd
feat: implement component list generation
Fernando-hub527 Nov 5, 2024
8ea21e9
test: validate provider builder props definition
Fernando-hub527 Nov 14, 2024
a0e4fe1
feat: set provider builder props
Fernando-hub527 Nov 14, 2024
7bd595b
style: implement golint suggestions
Fernando-hub527 Nov 14, 2024
983385d
fix: avoid cyclic import between processor and Maroto
Fernando-hub527 Nov 15, 2024
7b2783f
test: validate document generation
Fernando-hub527 Nov 16, 2024
4ed6f23
feat: implement document generation
Fernando-hub527 Nov 16, 2024
65e8eef
feat: load documents via repository
Fernando-hub527 Nov 17, 2024
03a874d
fix: fix errors in adding pages
Fernando-hub527 Nov 30, 2024
f7eff52
test: validate simple pdf addition
Fernando-hub527 Nov 30, 2024
3a5185c
feat: implement pdf genearition
Fernando-hub527 Nov 30, 2024
d63e32e
test: validate page addition example
Fernando-hub527 Nov 30, 2024
628edbe
feat: provide a method to check the source of the resource
Fernando-hub527 Dec 8, 2024
a717a31
fix: use fileimage to generate local images
Fernando-hub527 Dec 18, 2024
88dd24a
fix: validate execution of autorow example
Fernando-hub527 Dec 18, 2024
e172d85
fix: Keep the order of components added to the pdf
Fernando-hub527 Dec 24, 2024
80cfbeb
fix: load image dimensions in test
Fernando-hub527 Dec 25, 2024
fd79aaa
test: validate autorow example build
Fernando-hub527 Dec 25, 2024
0f30941
test: validate background example build
Fernando-hub527 Dec 26, 2024
189cfba
test: validate barcodegrid example build
Fernando-hub527 Dec 26, 2024
f8d348f
fix: allow adding more than one component in a column
Fernando-hub527 Dec 27, 2024
2c98929
feat: add cell props in row
Fernando-hub527 Dec 30, 2024
b3de0a8
test: validate billing example build
Fernando-hub527 Dec 30, 2024
3e0d2a2
test: validate cellstyle example build
Fernando-hub527 Dec 31, 2024
ad514b9
test: validate compression example build
Fernando-hub527 Dec 31, 2024
1979fd1
test: validate customdimensions example build
Fernando-hub527 Dec 31, 2024
62cdf26
test: validate customfont example build
Fernando-hub527 Jan 1, 2025
c4da9dd
test: validate custompage example build
Fernando-hub527 Jan 1, 2025
2d6c8ad
test: validate datamatrixgrid example build
Fernando-hub527 Jan 1, 2025
fc6cd29
test: validate disableautopagebreak example build
Fernando-hub527 Jan 1, 2025
61639de
test: validate build of footer and header example
Fernando-hub527 Jan 1, 2025
6f343dd
test: set the test build directory to allow pulling the image
Fernando-hub527 Jan 2, 2025
4eb910b
test: validate imagegrid example build
Fernando-hub527 Jan 2, 2025
0887a38
test: validate linegrid example build
Fernando-hub527 Jan 2, 2025
65cae52
test: validate lowmemory example build
Fernando-hub527 Jan 2, 2025
3b87045
test: validate margins example build
Fernando-hub527 Jan 2, 2025
029f0b2
test: validate maxgridsum example build
Fernando-hub527 Jan 2, 2025
0f18b29
test: validate metadata example build
Fernando-hub527 Jan 2, 2025
74c50da
test: validate orientation example build
Fernando-hub527 Jan 2, 2025
8a19f9b
test: validate pagenumber example build
Fernando-hub527 Jan 2, 2025
951b884
test: validate parallelism example build
Fernando-hub527 Jan 2, 2025
407e07e
test: validate protection example build
Fernando-hub527 Jan 2, 2025
90873ac
test: validate qrcodegrid example build
Fernando-hub527 Jan 2, 2025
69f162a
test: validate signature example build
Fernando-hub527 Jan 2, 2025
4cfe0e7
test: validate simplest example build
Fernando-hub527 Jan 2, 2025
f8d6172
test: validate textgrid example build
Fernando-hub527 Jan 2, 2025
6123805
Merge branch 'master' into doc-processor
Fernando-hub527 Jan 2, 2025
68e1ccc
test: fix error in expected structure for autorow example
Fernando-hub527 Jan 2, 2025
1af0abe
fix: include bottom property in text
Fernando-hub527 Jan 2, 2025
7d8c3c8
mocks: fix repeating interface names
Fernando-hub527 Jan 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/assets/examples/autorow/v2/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
)

func TestGetMaroto(t *testing.T) {
test.SetupTestDir(t)

// Act
sut := GetMaroto()

Expand Down
1 change: 1 addition & 0 deletions docs/assets/examples/imagegrid/v2/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
)

func TestGetMaroto(t *testing.T) {
test.SetupTestDir(t)
// Act
sut := GetMaroto()

Expand Down
169 changes: 169 additions & 0 deletions internal/fixture/processorfixture.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
package fixture

import (
"time"

"github.com/johnfercher/maroto/v2/pkg/processor/mappers"
"github.com/johnfercher/maroto/v2/pkg/processor/mappers/buildermapper"
"github.com/johnfercher/maroto/v2/pkg/processor/mappers/components/codemapper"
"github.com/johnfercher/maroto/v2/pkg/processor/mappers/components/colmapper"
"github.com/johnfercher/maroto/v2/pkg/processor/mappers/components/imagemapper"
"github.com/johnfercher/maroto/v2/pkg/processor/mappers/components/linemapper"
"github.com/johnfercher/maroto/v2/pkg/processor/mappers/components/listmapper"
"github.com/johnfercher/maroto/v2/pkg/processor/mappers/components/pagemapper"
"github.com/johnfercher/maroto/v2/pkg/processor/mappers/components/rowmapper"
"github.com/johnfercher/maroto/v2/pkg/processor/mappers/components/signaturemapper"
"github.com/johnfercher/maroto/v2/pkg/processor/mappers/components/textmapper"
"github.com/johnfercher/maroto/v2/pkg/processor/mappers/propsmapper"
)

func MapperRow() *rowmapper.Row {
return &rowmapper.Row{
Height: 0,
Cols: make([]mappers.Componentmapper, 0),
}
}

func MapperPage() *pagemapper.Page {
return &pagemapper.Page{
SourceKey: "template_page_1",
Rows: make([]mappers.OrderedComponents, 0),
}
}

func MapperList() *listmapper.List {
return &listmapper.List{}
}

func Barcode() *codemapper.Barcode {
return &codemapper.Barcode{Order: 1}
}

func Matrixcode() *codemapper.Matrixcode {
return &codemapper.Matrixcode{Order: 1}
}

func Qrcode() *codemapper.Qrcode {
return &codemapper.Qrcode{Order: 1}
}

func Image() *imagemapper.Image {
return &imagemapper.Image{Order: 1}
}

func Line() *linemapper.Line {
return &linemapper.Line{Order: 1}
}

func Signature() *signaturemapper.Signature {
return &signaturemapper.Signature{Order: 1}
}

func Text() *textmapper.Text {
return &textmapper.Text{Order: 1}
}

func Metadata() *propsmapper.Metadata {
creation := time.Now()
return &propsmapper.Metadata{
Author: &propsmapper.Utf8Text{Text: "Author", UTF8: true}, Creator: &propsmapper.Utf8Text{Text: "Creator", UTF8: true},
Subject: &propsmapper.Utf8Text{Text: "Subject", UTF8: true}, Title: &propsmapper.Utf8Text{Text: "Title", UTF8: true},
CreationDate: &creation, KeywordsStr: &propsmapper.Utf8Text{Text: "KeywordsStr", UTF8: true},
}
}

func BuilderProps() *buildermapper.Builder {
time, _ := time.Parse("2006-01-02 15:04:05", "2024-10-09 14:30:00")
return &buildermapper.Builder{
Dimensions: &propsmapper.Dimensions{
Width: 10.0,
Height: 10.0,
},
Margins: &propsmapper.Margins{
Left: 10.0,
Right: 10.0,
Top: 10.0,
Bottom: 10.0,
},
SequentialMode: false,
ConcurrentMode: 10,
SequentialLowMemoryMode: -1,
Debug: true,
MaxGridSize: 10,
DefaultFont: &propsmapper.Font{
Family: "Arial",
Style: "bold",
Size: 10,
Color: &propsmapper.Color{
Red: 10,
Green: 100,
Blue: 150,
},
},
PageNumber: &propsmapper.PageNumber{
Pattern: "pattern_test",
Place: "place_test",
Family: "family_test",
Style: "style_test",
Size: 10.0,
Color: &propsmapper.Color{
Red: 10,
Green: 100,
Blue: 150,
},
},
CustomFonts: []*propsmapper.CustomFont{
{Family: "family_test", Style: "style_test", File: "file_test"},
{Family: "family_test2", Style: "style_test2", File: "file_test2"},
},
Protection: &propsmapper.Protection{
Type: 4,
UserPassword: "senha123",
OwnerPassword: "senha123",
},
Compression: true,
PageSize: "T",
Orientation: "vertical",
Metadata: &propsmapper.Metadata{
Author: &propsmapper.Utf8Text{Text: "user_test", UTF8: true},
Creator: &propsmapper.Utf8Text{Text: "user_test", UTF8: true},
Subject: &propsmapper.Utf8Text{Text: "test", UTF8: true},
Title: &propsmapper.Utf8Text{Text: "report", UTF8: true},
CreationDate: &time,
KeywordsStr: &propsmapper.Utf8Text{Text: "test", UTF8: true},
},
DisableAutoPageBreak: true,
GenerationMode: "concurrent",
}
}

func Row(sourceKeyRow, sourceKeyText string) *rowmapper.Row {
col := colmapper.Col{
Size: 12,
Components: []mappers.OrderedComponents{},
}

return &rowmapper.Row{
Height: 10,
SourceKey: sourceKeyRow,
Cols: []mappers.Componentmapper{&col},
}
}

func Page(sourceKeyPage, sourceKeyRow, sourceKeyText string) *pagemapper.Page {
col := colmapper.Col{
Size: 12,
Components: []mappers.OrderedComponents{},
}

return &pagemapper.Page{
SourceKey: sourceKeyPage,
Rows: []mappers.OrderedComponents{
&rowmapper.Row{
Height: 10,
SourceKey: sourceKeyRow,
Cols: []mappers.Componentmapper{&col},
},
},
}
}
4 changes: 2 additions & 2 deletions internal/providers/gofpdf/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ type Dependencies struct {
Cfg *entity.Config
}

// Builder is the dependencies builder for gofpdf
type Builder interface {
// BuilderProvider is the dependencies builder for gofpdf
type BuilderProvider interface {
Build(cfg *entity.Config, cache cache.Cache) *Dependencies
}

Expand Down
21 changes: 11 additions & 10 deletions metricsdecorator_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package maroto
package maroto_test

import (
"fmt"
"testing"

"github.com/johnfercher/maroto/v2"
"github.com/johnfercher/maroto/v2/pkg/core/entity"

"github.com/johnfercher/maroto/v2/pkg/components/text"
Expand All @@ -20,7 +21,7 @@ import (

func TestNewMetricsDecorator(t *testing.T) {
// Act
sut := NewMetricsDecorator(nil)
sut := maroto.NewMetricsDecorator(nil)

// Assert
assert.NotNil(t, sut)
Expand All @@ -37,7 +38,7 @@ func TestMetricsDecorator_AddPages(t *testing.T) {
inner.EXPECT().AddPages(pg)
inner.EXPECT().Generate().Return(docToReturn, nil)

sut := NewMetricsDecorator(inner)
sut := maroto.NewMetricsDecorator(inner)

// Act
sut.AddPages(pg)
Expand Down Expand Up @@ -67,7 +68,7 @@ func TestMetricsDecorator_AddRow(t *testing.T) {
inner.EXPECT().AddRow(10.0, col).Return(nil)
inner.EXPECT().Generate().Return(docToReturn, nil)

sut := NewMetricsDecorator(inner)
sut := maroto.NewMetricsDecorator(inner)

// Act
sut.AddRow(10, col)
Expand Down Expand Up @@ -97,7 +98,7 @@ func TestMetricsDecorator_AddRows(t *testing.T) {
inner.EXPECT().AddRows(row)
inner.EXPECT().Generate().Return(docToReturn, nil)

sut := NewMetricsDecorator(inner)
sut := maroto.NewMetricsDecorator(inner)

// Act
sut.AddRows(row)
Expand Down Expand Up @@ -128,7 +129,7 @@ func TestMetricsDecorator_GetStructure(t *testing.T) {
inner.EXPECT().GetStructure().Return(&node.Node[core.Structure]{})
inner.EXPECT().Generate().Return(docToReturn, nil)

sut := NewMetricsDecorator(inner)
sut := maroto.NewMetricsDecorator(inner)
sut.AddRows(row)

// Act
Expand Down Expand Up @@ -156,7 +157,7 @@ func TestMetricsDecorator_FitlnCurrentPage(t *testing.T) {
inner.EXPECT().FitlnCurrentPage(10.0).Return(true)
inner.EXPECT().FitlnCurrentPage(20.0).Return(false)

sut := NewMetricsDecorator(inner)
sut := maroto.NewMetricsDecorator(inner)

// Act & Assert
assert.True(t, sut.FitlnCurrentPage(10))
Expand All @@ -171,7 +172,7 @@ func TestMetricsDecorator_GetCurrentConfig(t *testing.T) {
inner := mocks.NewMaroto(t)
inner.EXPECT().GetCurrentConfig().Return(cfgToReturn)

sut := NewMetricsDecorator(inner)
sut := maroto.NewMetricsDecorator(inner)

// Act
cfg := sut.GetCurrentConfig()
Expand All @@ -188,7 +189,7 @@ func TestMetricsDecorator_RegisterHeader(t *testing.T) {
inner.EXPECT().RegisterHeader(row).Return(nil)
inner.EXPECT().Generate().Return(&core.Pdf{}, nil)

sut := NewMetricsDecorator(inner)
sut := maroto.NewMetricsDecorator(inner)

// Act
err := sut.RegisterHeader(row)
Expand All @@ -214,7 +215,7 @@ func TestMetricsDecorator_RegisterFooter(t *testing.T) {
inner.EXPECT().RegisterFooter(row).Return(nil)
inner.EXPECT().Generate().Return(&core.Pdf{}, nil)

sut := NewMetricsDecorator(inner)
sut := maroto.NewMetricsDecorator(inner)

// Act
err := sut.RegisterFooter(row)
Expand Down
Loading
Loading