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

Kick-off of Maroto project #1

Merged
merged 1 commit into from
May 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@

# JetBrains
.idea

# PDFs
*.pdf
50 changes: 50 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Gopkg.toml example
#
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"
#
# [prune]
# non-go = false
# go-tests = true
# unused-packages = true


[[constraint]]
name = "github.com/jung-kurt/gofpdf"
version = "1.4.2"

[prune]
go-tests = true
unused-packages = true
Binary file added assets/images/dhl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/mercado_livre.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions enums/horizontal_align.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package enums

type HorizontalAlign int

const (
Left HorizontalAlign = 0
Right HorizontalAlign = 1
CenterH HorizontalAlign = 2
)
7 changes: 7 additions & 0 deletions enums/orientation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package enums

type Orientation int

const (
Vertical Orientation = 0
)
7 changes: 7 additions & 0 deletions enums/page_size.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package enums

type PageSize int

const (
A4 PageSize = 0
)
9 changes: 9 additions & 0 deletions enums/vertical_align.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package enums

type VerticalAlign int

const (
Top VerticalAlign = 0
Bottom VerticalAlign = 1
CenterV VerticalAlign = 2
)
11 changes: 11 additions & 0 deletions font/family.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package font

type Family int

const (
Arial Family = 0
Helvetica Family = 1
Symbol Family = 2
ZapBats Family = 3
Courier Family = 4
)
109 changes: 109 additions & 0 deletions font/font.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
package font

import (
"github.com/jung-kurt/gofpdf"
)

type Font interface {
SetFamily(family Family)
SetStyle(style Style)
SetSize(size float64)
SetFont(family Family, style Style, size float64)
GetFamily() Family
GetStyle() Style
GetSize() float64
GetFont() (Family, Style, float64)
GetStyleString(style Style) string
GetFamilyString(font Family) string
}

type font struct {
pdf gofpdf.Pdf
size float64
family Family
style Style
}

func NewFont(pdf gofpdf.Pdf, size float64, family Family, style Style) Font {
return &font{
pdf,
size,
family,
style,
}
}

func (f *font) GetFamily() Family {
return f.family
}

func (f *font) GetStyle() Style {
return f.style
}

func (f *font) GetSize() float64 {
return f.size
}

func (f *font) GetFont() (Family, Style, float64) {
return f.family, f.style, f.size
}

func (f *font) SetFamily(family Family) {
f.family = family
familyString := f.GetFamilyString(f.family)
styleString := f.GetStyleString(f.style)

f.pdf.SetFont(familyString, styleString, f.size)
}

func (f *font) SetStyle(style Style) {
f.style = style
styleString := f.GetStyleString(f.style)

f.pdf.SetFontStyle(styleString)
}

func (f *font) SetSize(size float64) {
f.size = size
f.pdf.SetFontSize(f.size)
}

func (f *font) SetFont(family Family, style Style, size float64) {
f.family = family
f.style = style
f.size = size

familyString := f.GetFamilyString(f.family)
styleString := f.GetStyleString(f.style)

f.pdf.SetFont(familyString, styleString, f.size)
}

func (f *font) GetFamilyString(font Family) string {
switch font {
case Courier:
return "courier"
case Helvetica:
return "helvetica"
case Symbol:
return "symbol"
case ZapBats:
return "zapfdingbats"
default:
return "arial"
}
}

func (f *font) GetStyleString(style Style) string {
switch style {
case Italic:
return "I"
case Bold:
return "B"
case BoldItalic:
return "BI"
default:
return ""
}
}
Loading