forked from Mindinventory/Golang-HTML-TO-PDF-Converter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
executable file
·39 lines (32 loc) · 777 Bytes
/
main.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
package main
import (
u "Golang-HTMLTOPDF-Converter/pdfGenerator"
"fmt"
)
func main() {
r := u.NewRequestPdf("")
//html template path
templatePath := "templates/sample.html"
//path for download pdf
outputPath := "storage/example.pdf"
//html template data
templateData := struct {
Title string
Description string
Company string
Contact string
Country string
}{
Title: "HTML to PDF generator",
Description: "This is the simple HTML to PDF file.",
Company: "Jhon Lewis",
Contact: "Maria Anders",
Country: "Germany",
}
if err := r.ParseTemplate(templatePath, templateData); err == nil {
ok, _ := r.GeneratePDF(outputPath)
fmt.Println(ok, "pdf generated successfully")
} else {
fmt.Println(err)
}
}