-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
41 lines (35 loc) · 906 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
40
41
// Package main ...
package main
import (
"fmt"
"log"
"os"
"github.com/go-rod/rod"
"github.com/go-rod/rod/lib/proto"
"github.com/go-rod/rod/lib/utils"
"github.com/ysmood/gson"
)
func main() {
// get local file
path, err := os.Getwd()
if err != nil {
log.Println(err)
}
filepath := path + "/pdf_public/index.html"
outfilePath := "./public/karl_haworth_resume.pdf"
page := rod.New().MustConnect().MustPage("file://" + filepath).MustWaitLoad()
page.MustPDF(outfilePath)
// customized version
pdf, _ := page.PDF(&proto.PagePrintToPDF{
PaperWidth: gson.Num(8.5),
PaperHeight: gson.Num(11),
MarginTop: gson.Num(0.15),
MarginBottom: gson.Num(0.15),
MarginRight: gson.Num(0.15),
MarginLeft: gson.Num(0.15),
Scale: gson.Num(0.95),
PrintBackground: true,
})
_ = utils.OutputFile(outfilePath, pdf)
fmt.Println("wrote " + outfilePath)
}