-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
customizing to have more events as templates
- Loading branch information
1 parent
2531ce1
commit a427970
Showing
9 changed files
with
99 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
SENDGRID_API_KEY= | ||
SENDGRID_CERTIFICATE_TEMPLATE= | ||
SENDGRID_CERTIFICATE_TEMPLATE= | ||
SENDGRID_SENDER_NAME= | ||
SENDGRID_SENDER_EMAIL= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ func Send(a *data.Attendant) error { | |
|
||
m := mail.NewV3Mail() | ||
|
||
from := mail.NewEmail("DevParaná", "[email protected]") | ||
from := mail.NewEmail(os.Getenv("SENDGRID_SENDER_NAME"), os.Getenv("SENDGRID_SENDER_EMAIL")) | ||
to := mail.NewEmail(a.Name, a.Email) | ||
|
||
m.SetFrom(from) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package templates | ||
|
||
import ( | ||
"github.com/ferfabricio/certificados-devparana-go/internal/data" | ||
"github.com/signintech/gopdf" | ||
) | ||
|
||
func DevParanaNaEstrada2022(attendent data.Attendant, city *data.City) (*gopdf.GoPdf, error) { | ||
var err error | ||
|
||
pdf := &gopdf.GoPdf{} | ||
pdf.Start(gopdf.Config{PageSize: *gopdf.PageSizeA4Landscape}) | ||
pdf.AddPage() | ||
|
||
tpl := pdf.ImportPage("./assets/pdf/template-devparana-na-estrada-2022.pdf", 1, "/MediaBox") | ||
pdf.UseImportedTemplate(tpl, 0, 0, gopdf.PageSizeA4Landscape.W, gopdf.PageSizeA4Landscape.H) | ||
|
||
err = pdf.AddTTFFont("aleo", "./assets/fonts/Aleo-Bold.ttf") | ||
if err != nil { | ||
return nil, err | ||
} | ||
err = pdf.AddTTFFont("opensans", "./assets/fonts/Open-Sans.ttf") | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
err = pdf.SetFont("aleo", "", 25) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
s, err := pdf.MeasureTextWidth(attendent.Name) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
pdf.SetXY((gopdf.PageSizeA4Landscape.W/2)-(s/2), 270) | ||
|
||
err = pdf.Text(attendent.Name) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
err = pdf.SetFont("opensans", "", 13) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
pdf.SetXY(350, 400) | ||
|
||
err = pdf.Text(city.Name) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
pdf.SetXY(350, 420) | ||
|
||
err = pdf.Text(city.Date) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return pdf, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package templates | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/ferfabricio/certificados-devparana-go/internal/data" | ||
"github.com/signintech/gopdf" | ||
) | ||
|
||
func getTemplate(t string, a data.Attendant, c *data.City, p *gopdf.GoPdf) (*gopdf.GoPdf, error) { | ||
switch t { | ||
case "devparana_na_estrada_2022": | ||
return DevParanaNaEstrada2022(a, c) | ||
} | ||
return nil, errors.New("template not implemented") | ||
} | ||
|
||
func Prepare(a data.Attendant, c *data.City) (*gopdf.GoPdf, error) { | ||
pdf := &gopdf.GoPdf{} | ||
|
||
return getTemplate(c.Template, a, c, pdf) | ||
} |