fix:订单发票调整

This commit is contained in:
momo
2023-10-24 15:22:39 +08:00
parent 56f4460995
commit ef06ecd774
2 changed files with 47 additions and 14 deletions

View File

@@ -3,15 +3,16 @@ package pdf
import (
"encoding/base64"
"errors"
"github.com/SebastiaanKlippert/go-wkhtmltopdf"
"strings"
"github.com/SebastiaanKlippert/go-wkhtmltopdf"
)
/*
html转 Pdf
outFile为空则不保存(使用该方法需要安装工具 sudo apt-get install wkhtmltopdf)
*/
func HtmlToPdfBase64(content string, dataType string, outFile ...string) (string, error) {
func HtmlToPdfBase64(content string, dataType string, pageSize string, outFile ...string) (string, error) {
pdfg, err := wkhtmltopdf.NewPDFGenerator()
if err != nil {
return "", err
@@ -27,7 +28,7 @@ func HtmlToPdfBase64(content string, dataType string, outFile ...string) (string
//模式
pdfg.Orientation.Set(wkhtmltopdf.OrientationPortrait)
//pdf尺寸默认A4纸
pdfg.PageSize.Set(wkhtmltopdf.PageSizeA4)
pdfg.PageSize.Set(pageSize)
// Create PDF document in memory
if err = pdfg.Create(); err != nil {
return "", err