Skip to content

Commit

Permalink
V2 bar (#261)
Browse files Browse the repository at this point in the history
* Standardize nodes

* Barcode example done
  • Loading branch information
johnfercher authored Sep 15, 2023
1 parent 120078a commit 383537a
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 11 deletions.
File renamed without changes.
87 changes: 87 additions & 0 deletions internal/examples/barcodegrid/v2/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package main

import (
"fmt"
v2 "github.com/johnfercher/maroto/pkg/v2"
"github.com/johnfercher/maroto/pkg/v2/code/barcode"
"github.com/johnfercher/maroto/pkg/v2/grid/col"
"github.com/johnfercher/maroto/pkg/v2/grid/row"
"github.com/johnfercher/maroto/pkg/v2/providers"
"github.com/johnfercher/maroto/pkg/v2/size"
"os"
"time"

"github.com/johnfercher/maroto/pkg/props"
)

func main() {
begin := time.Now()
provider := providers.NewGofpdf(size.A4)
maroto := v2.NewMaroto(provider, "internal/examples/pdfs/barcodegridv2.pdf")
m := v2.NewMarotoMetrified(maroto)

c1 := col.New(2).Add(barcode.New("https://github.com/johnfercher/maroto", props.Barcode{
Percent: 50,
}))
c2 := col.New(4).Add(barcode.New("https://github.com/johnfercher/maroto", props.Barcode{
Percent: 75,
}))
c3 := col.New(6).Add(barcode.New("https://github.com/johnfercher/maroto", props.Barcode{
Percent: 100,
}))

r1 := row.New(40).Add(c1, c2, c3)

c4 := col.New(2).Add(barcode.New("https://github.com/johnfercher/maroto", props.Barcode{
Center: true,
Percent: 50,
}))
c5 := col.New(4).Add(barcode.New("https://github.com/johnfercher/maroto", props.Barcode{
Center: true,
Percent: 75,
}))
c6 := col.New(6).Add(barcode.New("https://github.com/johnfercher/maroto", props.Barcode{
Center: true,
Percent: 100,
}))

r2 := row.New(40).Add(c4, c5, c6)

c7 := col.New(6).Add(barcode.New("https://github.com/johnfercher/maroto", props.Barcode{
Percent: 50,
}))
c8 := col.New(4).Add(barcode.New("https://github.com/johnfercher/maroto", props.Barcode{
Percent: 75,
}))
c9 := col.New(2).Add(barcode.New("https://github.com/johnfercher/maroto", props.Barcode{
Percent: 100,
}))

r3 := row.New(40).Add(c7, c8, c9)

c10 := col.New(6).Add(barcode.New("https://github.com/johnfercher/maroto", props.Barcode{
Center: true,
Percent: 50,
}))
c11 := col.New(4).Add(barcode.New("https://github.com/johnfercher/maroto", props.Barcode{
Center: true,
Percent: 75,
}))
c12 := col.New(2).Add(barcode.New("https://github.com/johnfercher/maroto", props.Barcode{
Center: true,
Percent: 100,
}))

r4 := row.New(40).Add(c10, c11, c12)

m.Add(r1, r2, r3, r4)

err := m.Generate()
if err != nil {
fmt.Println("Could not save PDF:", err)
os.Exit(1)
}

end := time.Now()
fmt.Println(end.Sub(begin))
}
11 changes: 0 additions & 11 deletions internal/examples/imagegrid/v2/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ func main() {
Center: true,
Percent: 80,
}))

c2 := col.New(4).Add(image.NewFromFile("internal/assets/images/biplane.jpg", props.Rect{
Center: true,
Percent: 80,
}))

c3 := col.New(6).Add(image.NewFromFile("internal/assets/images/biplane.jpg", props.Rect{
Center: true,
Percent: 80,
Expand All @@ -40,13 +38,11 @@ func main() {
Percent: 50,
Left: 10,
}))

c5 := col.New(4).Add(image.NewFromFile("internal/assets/images/biplane.jpg", props.Rect{
Center: false,
Percent: 50,
Top: 10,
}))

c6 := col.New(6).Add(image.NewFromFile("internal/assets/images/biplane.jpg", props.Rect{
Center: false,
Percent: 50,
Expand All @@ -61,12 +57,10 @@ func main() {
Center: true,
Percent: 80,
}))

c8 := col.New(4).Add(image.NewFromFile("internal/assets/images/biplane.jpg", props.Rect{
Center: true,
Percent: 80,
}))

r3 := row.New(40).Add(c7, c8)
m.Add(r3)

Expand All @@ -76,13 +70,11 @@ func main() {
Top: 5,
Left: 10,
}))

c10 := col.New(4).Add(image.NewFromFile("internal/assets/images/frontpage.png", props.Rect{
Center: false,
Percent: 80,
Top: 5,
}))

c11 := col.New(2).Add(image.NewFromFile("internal/assets/images/frontpage.png", props.Rect{
Center: false,
Percent: 80,
Expand All @@ -96,12 +88,10 @@ func main() {
Center: true,
Percent: 50,
}))

c13 := col.New(4).Add(image.NewFromFile("internal/assets/images/frontpage.png", props.Rect{
Center: true,
Percent: 50,
}))

c14 := col.New(2).Add(image.NewFromFile("internal/assets/images/frontpage.png", props.Rect{
Center: true,
Percent: 50,
Expand All @@ -114,7 +104,6 @@ func main() {
Center: true,
Percent: 80,
}))

c16 := col.New(6).Add(image.NewFromFile("internal/assets/images/frontpage.png", props.Rect{
Center: true,
Percent: 80,
Expand Down
Binary file modified internal/examples/pdfs/barcodegrid.pdf
Binary file not shown.
Binary file added internal/examples/pdfs/barcodegridv2.pdf
Binary file not shown.
Binary file modified internal/examples/pdfs/imagegrid.pdf
Binary file not shown.
Binary file modified internal/examples/pdfs/imagegridv2.pdf
Binary file not shown.

0 comments on commit 383537a

Please sign in to comment.