generated from VLADIMIR/template
up
This commit is contained in:
@@ -25,6 +25,11 @@ type Card struct {
|
||||
//go:embed fonts/DejaVuSansCondensed.ttf
|
||||
var font []byte
|
||||
|
||||
// RegisterFont adds the existing Cyrillic print font to a PDF document.
|
||||
func RegisterFont(pdf *fpdf.Fpdf) {
|
||||
pdf.AddUTF8FontFromBytes("teams", "", font)
|
||||
}
|
||||
|
||||
// Generate returns a PDF containing team QR-code cards.
|
||||
func Generate(cards []Card) ([]byte, error) {
|
||||
if len(cards) == 0 {
|
||||
@@ -33,7 +38,7 @@ func Generate(cards []Card) ([]byte, error) {
|
||||
pdf := fpdf.New("P", "mm", "A4", "")
|
||||
pdf.SetAutoPageBreak(false, 0)
|
||||
pdf.SetCellMargin(0)
|
||||
pdf.AddUTF8FontFromBytes("teams", "", font)
|
||||
RegisterFont(pdf)
|
||||
pdf.SetFillColor(0, 0, 0)
|
||||
const margin, width, height, qrSize = 10.0, 190.0 / 3, 277.0 / 4, 36.0
|
||||
for i, card := range cards {
|
||||
|
||||
Reference in New Issue
Block a user