From 1d1396b4c24bf2bc8ae223303bf5a384b0e0233d Mon Sep 17 00:00:00 2001 From: jfercher Date: Thu, 14 May 2020 09:58:36 -0300 Subject: [PATCH] Implement Add Page --- README.md | 35 +++++++++++++------------ internal/examples/billing/main.go | 1 - internal/examples/pdfs/barcodegrid.pdf | Bin 31139 -> 31139 bytes internal/examples/pdfs/billing.pdf | Bin 209330 -> 209330 bytes internal/examples/pdfs/sample1.pdf | Bin 670001 -> 669763 bytes internal/examples/pdfs/zpl.pdf | Bin 209941 -> 209941 bytes internal/examples/sample1/main.go | 8 ++---- pkg/pdf/example_test.go | 11 ++++++++ pkg/pdf/pdf.go | 16 ++++++++++- pkg/pdf/pdf_test.go | 14 ++++++++++ 10 files changed, 60 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index ab38fd93..397e05ad 100644 --- a/README.md +++ b/README.md @@ -23,36 +23,37 @@ go get -u github.com/johnfercher/maroto ``` ## Features - ![result](internal/assets/images/diagram.png) #### Grid System -* [Row](https://godoc.org/github.com/johnfercher/maroto/pkg/pdf#example-PdfMaroto-Row) -* [Col](https://godoc.org/github.com/johnfercher/maroto/pkg/pdf#example-PdfMaroto-Col) -* [ColSpace](https://godoc.org/github.com/johnfercher/maroto/pkg/pdf#example-PdfMaroto-ColSpace) -* [ColSpaces](https://godoc.org/github.com/johnfercher/maroto/pkg/pdf#example-PdfMaroto-ColSpaces) +* [Row](https://pkg.go.dev/github.com/johnfercher/maroto/pkg/pdf?tab=doc#PdfMaroto.Row) +* [Col](https://pkg.go.dev/github.com/johnfercher/maroto/pkg/pdf?tab=doc#PdfMaroto.Col) +* [ColSpace](https://pkg.go.dev/github.com/johnfercher/maroto/pkg/pdf?tab=doc#PdfMaroto.ColSpace) +* [AddPage](https://pkg.go.dev/github.com/johnfercher/maroto/pkg/pdf?tab=doc#PdfMaroto.AddPage) #### Components To Use Inside a Col -* [Text w/ automatic new lines](https://godoc.org/github.com/johnfercher/maroto/pkg/pdf#example-PdfMaroto-Text) -* [Signature](https://godoc.org/github.com/johnfercher/maroto/pkg/pdf#example-PdfMaroto-Signature) -* Image ([From file](https://godoc.org/github.com/johnfercher/maroto/pkg/pdf#example-PdfMaroto-FileImage) or [Base64](https://godoc.org/github.com/johnfercher/maroto/pkg/pdf#example-PdfMaroto-Base64Image)) -* [QrCode](https://godoc.org/github.com/johnfercher/maroto/pkg/pdf#PdfMaroto.QrCode) -* [Barcode](https://godoc.org/github.com/johnfercher/maroto/pkg/pdf#PdfMaroto.Barcode) +* [Text w/ automatic new lines](https://pkg.go.dev/github.com/johnfercher/maroto/pkg/pdf?tab=doc#PdfMaroto.Text) +* [Signature](https://pkg.go.dev/github.com/johnfercher/maroto/pkg/pdf?tab=doc#PdfMaroto.Signature) +* Image ([From file](https://pkg.go.dev/github.com/johnfercher/maroto/pkg/pdf?tab=doc#PdfMaroto.FileImage) or [Base64](https://pkg.go.dev/github.com/johnfercher/maroto/pkg/pdf?tab=doc#PdfMaroto.Base64Image)) +* [QrCode](https://pkg.go.dev/github.com/johnfercher/maroto/pkg/pdf?tab=doc#PdfMaroto.QrCode) +* [Barcode](https://pkg.go.dev/github.com/johnfercher/maroto/pkg/pdf?tab=doc#PdfMaroto.Barcode) #### Components To Use Outside a Row -* [TableList](https://godoc.org/github.com/johnfercher/maroto/pkg/pdf#example-PdfMaroto-TableList) -* [Line](https://godoc.org/github.com/johnfercher/maroto/pkg/pdf#example-PdfMaroto-Line) +* [TableList](https://pkg.go.dev/github.com/johnfercher/maroto/pkg/pdf?tab=doc#PdfMaroto.TableList) +* [Line](https://pkg.go.dev/github.com/johnfercher/maroto/pkg/pdf?tab=doc#PdfMaroto.Line) #### Components To Wrap Row, TableList and Line -* [RegisterHeader](https://godoc.org/github.com/johnfercher/maroto/pkg/pdf#PdfMaroto.RegisterHeader) -* [RegisterFooter](https://godoc.org/github.com/johnfercher/maroto/pkg/pdf#PdfMaroto.RegisterFooter) +* [RegisterHeader](https://pkg.go.dev/github.com/johnfercher/maroto/pkg/pdf?tab=doc#PdfMaroto.RegisterHeader) +* [RegisterFooter](https://pkg.go.dev/github.com/johnfercher/maroto/pkg/pdf?tab=doc#PdfMaroto.RegisterFooter) #### Others -* [Properties](https://godoc.org/github.com/johnfercher/maroto/pkg/props): most of the components has properties which you can use to customize appearance and behavior. -* [SetBorder](https://godoc.org/github.com/johnfercher/maroto#PdfMaroto.SetDebugMode): Used to draw rectangles in every row and column +* [Properties](https://pkg.go.dev/github.com/johnfercher/maroto/pkg/props?tab=doc): most of the components has properties which you can use to customize appearance and behavior. +* [SetBorder](https://pkg.go.dev/github.com/johnfercher/maroto/pkg/pdf?tab=doc#PdfMaroto.SetBorder): Used to draw rectangles in every row and column +* [SetBackgroundColor](https://pkg.go.dev/github.com/johnfercher/maroto/pkg/pdf?tab=doc#PdfMaroto.SetBackgroundColor): Used to change the background color of one cell. +* [SetPageMargins](https://pkg.go.dev/github.com/johnfercher/maroto/pkg/pdf?tab=doc#PdfMaroto.SetPageMargins): Customize the page margins * Automatic New Page: New pages are generated automatically when needed. * 100% Unicode -* Save: You can [save on disk](https://godoc.org/github.com/johnfercher/maroto/pkg/pdf#example-PdfMaroto-OutputFileAndClose) or export to a [base64 string](https://godoc.org/github.com/johnfercher/maroto/pkg/pdf#example-PdfMaroto-Output) +* Save: You can [save on disk](https://pkg.go.dev/github.com/johnfercher/maroto/pkg/pdf?tab=doc#PdfMaroto.OutputFileAndClose) or export to a [base64 string](https://pkg.go.dev/github.com/johnfercher/maroto/pkg/pdf?tab=doc#PdfMaroto.Output) #### Roadmap * Updated in [Issues](https://github.com/johnfercher/maroto/issues) diff --git a/internal/examples/billing/main.go b/internal/examples/billing/main.go index 0d9716fb..34e85496 100644 --- a/internal/examples/billing/main.go +++ b/internal/examples/billing/main.go @@ -21,7 +21,6 @@ func main() { m := pdf.NewMaroto(consts.Portrait, consts.A4) m.SetPageMargins(10, 15, 10) - //m.SetBorder(true) m.RegisterHeader(func() { m.Row(20, func() { diff --git a/internal/examples/pdfs/barcodegrid.pdf b/internal/examples/pdfs/barcodegrid.pdf index 1c1b87af1af8c9c0f2f8ede5dfa0cfbe12ca3b36..bd55c474fdb852f45fca8d6e6645fac4286def9b 100644 GIT binary patch delta 56 zcmV-80LTBM^8ust0kHjallFC%ll^otlZ$pTlaX~~lf8CmlV)`*lP+~QlO=an2{kb` OF)}qXF*CD-cOL>N`xrR@ delta 56 zcmZ4dnQ`%F#tnZ$-OrLxdC>B+gFto`x327N#xCng*PvhGvFFrbfnw+l>sE8yEqyatTfV delta 31 mcmdn=m}k>to`x327N#xCng*Q4Miz!f29~B~+l>sE8yEqyya`wU diff --git a/internal/examples/pdfs/sample1.pdf b/internal/examples/pdfs/sample1.pdf index f96da5527cd7b3a98d6cf2db39829b6269a99e6c..7a78db8e5cff9f3a31956df0e5a21e7f5d8f65b2 100644 GIT binary patch delta 2484 zcmZXQdpOhm8^_y>Y*aQ{&yvU?XTFl^9j9DWFg9Rnv zP@;ayT+Tj@ipuMKI-G|1zDO&=;pg<>8Umy3sIzRF?STM|_N}>xYjt+*4)1E#-EzR@Z4NGy8H+^!e1??6Q0S0Cyyqbl6DW#7bVLFWZNGk{{+9<39^F zH-yYR4t`hOdPeI|!j3O>zAi0c`VS44XvfaXpcCca%QsyyejCi;-{^F-atO&&&cBk# zM-LU7QC!%fx}l}HUeJ~J?k@{IyXY+#FEpM&J-khahY?_EUA%#A%fuLQ#DV^4A+)R> z{41)SwzrD19+OX%-RFi>QOY5$(3+_i*8$lPKiWE~&s1X}?j%$g-<=L=`Wr(R z7Dd}n`&VX6Ty*D(wM+`*4=HzDoN6*uyMNh3vdPR+EphCy&7s^(y+b1jfv^t>y*#*a zYwl=Ok}1m^)vdmCg7Pp|_cAgAxzYI&=t_Z|9+jufeJGUQCL=^T9?Xv2(HOLyCM&Yy z(Vx^=C+COUG#YVF zD{W`G6T%?U=EO8M$q#nE9EiTB{EA{F{X`YALCpiolb1SiJ}GMI(el@Azk7N4 zm0>1DvN)e5=?~RV*VfBO$@JZA_6Q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dee0891401d49e72265f80e599b4a354969c40 100644 GIT binary patch delta 158 zcmbRGf@kUro(-p&Cu_46$afZwWjHc834Vmp3&8MFS@hqkp0ZGg0hDOZMoW@4R zMg~R}hUU|!8Zn<>GBTYWZ_KPDWn^GtZfLGx00Ihm3S1!C$iU3p$YA