feat: better PDF

This commit is contained in:
2025-08-24 00:24:40 +02:00
parent 0267e6e578
commit 5b664234e9
18 changed files with 540 additions and 228 deletions

42
report/invoice/html.go Normal file
View File

@@ -0,0 +1,42 @@
package invoice
import (
"bytes"
"html/template"
_ "embed"
)
//go:embed assets/ch-cross.svg
var chCross template.HTML
//go:embed assets/scissors.svg
var scissors template.HTML
//go:embed assets/template.html
var htmlTemplate string
//go:embed assets/style.css
var style template.CSS
type tmpler struct {
Invoice
Cross template.HTML
Scissors template.HTML
}
func (i Invoice) CSS() template.CSS {
return style
}
func (i Invoice) HTML() (html template.HTML, err error) {
tmpl := template.Must(template.New("invoice").Parse(htmlTemplate))
data := tmpler{i, chCross, scissors}
buf := new(bytes.Buffer)
err = tmpl.Execute(buf, data)
html = template.HTML(buf.String())
return
}