/
pdfDraftFS.go
83 lines (76 loc) · 2.16 KB
/
pdfDraftFS.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package plexams
import (
"context"
"fmt"
"time"
"github.com/johnfercher/maroto/pkg/consts"
"github.com/johnfercher/maroto/pkg/pdf"
"github.com/johnfercher/maroto/pkg/props"
"github.com/rs/zerolog/log"
)
func (p *Plexams) DraftFS(ctx context.Context, outfile string) error {
m := pdf.NewMaroto(consts.Portrait, consts.A4)
m.SetPageMargins(10, 15, 10)
m.RegisterFooter(func() {
m.Row(20, func() {
m.Col(12, func() {
m.Text(fmt.Sprintf("Stand: %s Uhr, generiert mit https://github.com/obcode/plexams.go",
time.Now().Format("02.01.06, 15:04")), props.Text{
Top: 13,
Style: consts.BoldItalic,
Size: 8,
Align: consts.Left,
})
})
})
})
m.Row(6, func() {
m.Col(12, func() {
m.Text(
fmt.Sprintf("Vorläufiger Planungsstand der Prüfungen der FK07 im %s", p.semesterFull()), props.Text{
Top: 3,
Size: 12,
Style: consts.Bold,
Align: consts.Center,
})
})
})
m.Row(6, func() {
m.Col(12, func() {
m.Text(
fmt.Sprintf("%s <%s>", p.planer.Name, p.planer.Email), props.Text{
Top: 3,
Size: 12,
Style: consts.Normal,
Align: consts.Center,
})
})
})
m.Row(15, func() {
m.Col(12, func() {
m.Text(
"--- ENTWURF ---", props.Text{
Top: 3,
Size: 12,
Style: consts.Normal,
Align: consts.Center,
})
})
})
p.tableForProgram(ctx, "DC", "Data Science & Scientific Computing (DC)", m)
p.tableForProgram(ctx, "IB", "Wirtschaftsinformatik (IB)", m)
p.tableForProgram(ctx, "IC", "Scientific Computing (IC)", m)
p.tableForProgram(ctx, "IF", "Informatik (IF)", m)
p.tableForProgram(ctx, "IG", "Master Informatik (IG)", m)
p.tableForProgram(ctx, "IN", "Master Wirtschaftsinformatik (IN)", m)
p.tableForProgram(ctx, "IS", "Master Stochastic Engineering in Business and Finance (IS)", m)
p.tableForProgram(ctx, "IT", "Master IT-Sicherheit (IT)", m)
p.tableForProgram(ctx, "WD", "Wirtschaftsinformatik - Digitales Management (WD)", m)
p.tableForProgram(ctx, "WT", "Wirtschaftsinformatik - Informationstechnologie (WT)", m)
err := m.OutputFileAndClose(outfile)
if err != nil {
log.Error().Err(err).Msg("Could not save PDF")
return err
}
return nil
}