Skip to content

Instantly share code, notes, and snippets.

@johnfercher
Last active November 30, 2020 00:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnfercher/31f7e679aa79ee84dc62ed82918d6b6e to your computer and use it in GitHub Desktop.
Save johnfercher/31f7e679aa79ee84dc62ed82918d6b6e to your computer and use it in GitHub Desktop.
ZPL label created with Maroto
package main
import (
"fmt"
"github.com/johnfercher/maroto/pkg/consts"
"github.com/johnfercher/maroto/pkg/pdf"
"github.com/johnfercher/maroto/pkg/props"
"os"
"time"
)
func main() {
begin := time.Now()
m := pdf.NewMaroto(consts.Portrait, consts.Letter)
//m.SetBorder(true)
m.Row(40, func() {
m.Col(4, func() {
_ = m.FileImage("internal/assets/images/biplane.jpg", props.Rect{
Center: true,
Percent: 80,
})
})
m.Col(4, func() {
m.Text("Gopher International Shipping, Inc.", props.Text{
Top: 12,
Size: 20,
Extrapolate: true,
})
m.Text("1000 Shipping Gopher Golang TN 3691234 GopherLand (GL)", props.Text{
Size: 12,
Top: 22,
})
})
m.ColSpace(4)
})
m.Line(10)
m.Row(40, func() {
m.Col(4, func() {
m.Text("João Sant'Ana 100 Main Street Stringfield TN 39021 United Stats (USA)", props.Text{
Size: 15,
Top: 12,
})
})
m.ColSpace(4)
m.Col(4, func() {
m.QrCode("https://github.com/johnfercher/maroto", props.Rect{
Center: true,
Percent: 75,
})
})
})
m.Line(10)
m.Row(100, func() {
m.Col(12, func() {
_ = m.Barcode("https://github.com/johnfercher/maroto", props.Barcode{
Center: true,
Percent: 70,
})
m.Text("https://github.com/johnfercher/maroto", props.Text{
Size: 20,
Align: consts.Center,
Top: 65,
})
})
})
m.SetBorder(true)
m.Row(40, func() {
m.Col(6, func() {
m.Text("CODE: 123412351645231245564 DATE: 20-07-1994 20:20:33", props.Text{
Size: 15,
Top: 14,
})
})
m.Col(6, func() {
m.Text("CA", props.Text{
Top: 1,
Size: 85,
Align: consts.Center,
})
})
})
m.SetBorder(false)
err := m.OutputFileAndClose("internal/examples/pdfs/zpl.pdf")
if err != nil {
fmt.Println("Could not save PDF:", err)
os.Exit(1)
}
end := time.Now()
fmt.Println(end.Sub(begin))
}
@vit1251
Copy link

vit1251 commented Nov 30, 2020

Do u have any idea how to embed Bitmap font type in PDF?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment