mirror of
https://github.com/mindoc-org/mindoc.git
synced 2025-06-28 15:45:35 +08:00
*
This commit is contained in:
parent
4b264670a7
commit
a438b8104d
26
utils/pdf.go
26
utils/pdf.go
@ -1,28 +1,22 @@
|
|||||||
package utils
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/signintech/gopdf"
|
"github.com/jung-kurt/gofpdf"
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
)
|
)
|
||||||
func ConverterPdf(output string,htmlList map[string]string) error {
|
func ConverterPdf(output string,htmlList map[string]string) error {
|
||||||
pdf := gopdf.GoPdf{}
|
|
||||||
pdf.Start(gopdf.Config{PageSize: gopdf.Rect{W: 595.28, H: 841.89}})
|
pdf := gofpdf.New("P", "mm", "A4", "./static/pdf-fonts/msyh.ttf")
|
||||||
|
|
||||||
pdf.AddPage()
|
pdf.AddPage()
|
||||||
|
|
||||||
err := pdf.AddTTFFont("HDZB_5", "./static/pdf-fonts/msyh.ttf")
|
pdf.SetFont("微软雅黑","B",14)
|
||||||
if err != nil {
|
pdf.Cell(40, 10, "Hello, world")
|
||||||
beego.Error("ConverterPdf => ",err)
|
err := pdf.OutputFileAndClose("hello.pdf")
|
||||||
return err
|
|
||||||
}
|
|
||||||
err = pdf.SetFont("HDZB_5", "", 14)
|
|
||||||
if err != nil {
|
|
||||||
beego.Error("ConverterPdf => " , err)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
pdf.Cell(nil, "您好")
|
|
||||||
pdf.WritePdf(output)
|
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
beego.Error(err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user