
Product
Go Support Is Now Generally Available
Socket's Go support is now generally available, bringing automatic scanning and deep code analysis to all users with Go projects.
github.com/andreyhoffmann1103/maroto
A Maroto way to create PDFs. Maroto is inspired in Bootstrap and uses Gofpdf. Fast and simple.
Maroto definition: Brazilian expression, means an astute/clever/intelligent person.
You can write your PDFs like you are creating a site using Bootstrap. A Row may have many Cols, and a Col may have many components. 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.
go get
:go get -u github.com/johnfercher/maroto
dep
:dep ensure -add github.com/johnfercher/maroto
In the PDFs folder there are the PDFs generated using Maroto, and in the examples folder there are subfolders with the code to generate the PDFs.
func main() {
m := maroto.NewMaroto(maroto.Portrait, maroto.A4)
//m.SetDebugMode(true)
byteSlices, _ := ioutil.ReadFile("examples/internal/assets/images/biplane.jpg")
base64 := base64.StdEncoding.EncodeToString(byteSlices)
headerSmall, smallContent := getSmallContent()
headerMedium, mediumContent := getMediumContent()
m.RegisterHeader(func() {
m.Row(20, func() {
m.Col(func() {
m.Base64Image(base64, maroto.Jpg, maroto.RectProp{
Percent: 70,
})
})
m.ColSpaces(2)
m.Col(func() {
m.QrCode("https://github.com/johnfercher/maroto", maroto.RectProp{
Percent: 75,
})
})
m.Col(func() {
id := "https://github.com/johnfercher/maroto"
_ = m.Barcode(id, maroto.BarcodeProp{
Proportion: maroto.Proportion{50, 10},
Percent: 75,
})
m.Text(id, maroto.TextProp{
Size: 7,
Align: maroto.Center,
Top: 16,
})
})
})
m.Line(1.0)
m.Row(12, func() {
m.Col(func() {
m.FileImage("examples/internal/assets/images/gopherbw.png")
})
m.ColSpace()
m.Col(func() {
m.Text("Packages Report: Daily", maroto.TextProp{
Top: 4,
})
m.Text("Type: Small, Medium", maroto.TextProp{
Top: 10,
})
})
m.ColSpace()
m.Col(func() {
m.Text("20/07/1994", maroto.TextProp{
Size: 10,
Style: maroto.BoldItalic,
Top: 7.5,
Family: maroto.Helvetica,
})
})
})
m.Line(1.0)
m.Row(22, func() {
m.Col(func() {
m.Text(fmt.Sprintf("Small: %d, Medium %d", len(smallContent), len(mediumContent)), maroto.TextProp{
Size: 15,
Style: maroto.Bold,
Align: maroto.Center,
Top: 9,
})
m.Text("Brasil / São Paulo", maroto.TextProp{
Size: 12,
Align: maroto.Center,
Top: 17,
})
})
})
m.Line(1.0)
})
m.TableList(headerSmall, smallContent)
m.TableList(headerMedium, mediumContent, maroto.TableListProp{
Align: maroto.Center,
HeaderProp: maroto.FontProp{
Family: maroto.Courier,
Style: maroto.BoldItalic,
},
ContentProp: maroto.FontProp{
Family: maroto.Courier,
Style: maroto.Italic,
},
})
m.Row(40, func() {
m.Col(func() {
m.Signature("Signature 1", maroto.FontProp{
Family: maroto.Courier,
Style: maroto.BoldItalic,
Size: 9,
})
})
m.Col(func() {
m.Signature("Signature 2")
})
m.Col(func() {
m.Signature("Signature 3")
})
})
_ = m.OutputFileAndClose("examples/internal/pdfs/sample1.pdf")
}
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket's Go support is now generally available, bringing automatic scanning and deep code analysis to all users with Go projects.
Security News
vlt adds real-time security selectors powered by Socket, enabling developers to query and analyze package risks directly in their dependency graph.
Security News
CISA extended MITRE’s CVE contract by 11 months, avoiding a shutdown but leaving long-term governance and coordination issues unresolved.