mindoc/utils/pdf.go

23 lines
419 B
Go
Raw Normal View History

2017-05-05 18:02:52 +08:00
package utils
import (
2017-05-05 18:16:05 +08:00
"github.com/jung-kurt/gofpdf"
2017-05-05 18:02:52 +08:00
"github.com/astaxie/beego"
)
func ConverterPdf(output string,htmlList map[string]string) error {
2017-05-05 18:16:05 +08:00
pdf := gofpdf.New("P", "mm", "A4", "./static/pdf-fonts/msyh.ttf")
2017-05-05 18:02:52 +08:00
pdf.AddPage()
2017-05-05 18:16:05 +08:00
pdf.SetFont("微软雅黑","B",14)
pdf.Cell(40, 10, "Hello, world")
err := pdf.OutputFileAndClose("hello.pdf")
2017-05-05 18:02:52 +08:00
if err != nil {
2017-05-05 18:16:05 +08:00
beego.Error(err)
2017-05-05 18:02:52 +08:00
return err
}
return nil
}