feat: better PDF
This commit is contained in:
42
report/invoice/html.go
Normal file
42
report/invoice/html.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user