-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
55 lines (41 loc) · 1.12 KB
/
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package main
import (
"os"
wk "github.com/SebastiaanKlippert/go-wkhtmltopdf"
"github.com/hiromaily/golibs/pdf"
)
func main() {
// Create PDF from URL
createPDFWithURL()
// Create PDF from file
createPDFWithFile()
// version2 for json
//pdf.NewPDFGeneratorFromJSON()
// version3 for json
//pdf.NewPDFGeneratorFromJSON2()
}
func createConfig() *pdf.ConfigPDF {
config := pdf.ConfigPDF{
PageSize: "",
Orientation: wk.OrientationPortrait,
Dpi: 300,
Grayscale: true,
}
return &config
}
func createPDFWithURL() {
// Create PDF from URL
url := "https://godoc.org/github.com/SebastiaanKlippert/go-wkhtmltopdf"
output := "./output/godoc.pdf"
cr := pdf.CreateFromURL{URL: url, ConfigPDF: createConfig()}
pdf.NewPDFGenerator(&cr, output)
}
func createPDFWithFile() {
// Create PDF from file
path := os.Getenv("GOPATH") + "/src/github.com/hiromaily/golibs/pdf/cmd/"
//filePath := "testfiles/html5.html"
filePath := "testfiles/tables/index.html"
output2 := "./output/html5.pdf"
cr2 := pdf.CreateFromFile{FilePath: path + filePath, ConfigPDF: createConfig()}
pdf.NewPDFGenerator(&cr2, output2)
}