From 852153e960753ed46a3a5fff9f778e67f91d7f71 Mon Sep 17 00:00:00 2001 From: Yabo <386139859@qq.com> Date: Sat, 13 Jan 2024 10:46:38 +0800 Subject: [PATCH] :bug: gen pdf --- utils/genPdf.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/utils/genPdf.go b/utils/genPdf.go index 6e426a65..d4be9c0b 100644 --- a/utils/genPdf.go +++ b/utils/genPdf.go @@ -4,6 +4,7 @@ import ( "bytes" "fmt" "os" + "path/filepath" "runtime" "github.com/SebastiaanKlippert/go-wkhtmltopdf" @@ -28,11 +29,15 @@ func (p *PdfOption) GenPdf(buf *bytes.Buffer) (err error) { if p.CoverPath != "" { pdfg.Cover.EnableLocalFileAccess.Set(true) - + dir, err := CurrentDir() + if err != nil { + pdfg.Cover.EnableLocalFileAccess.Set(false) + } + dir = filepath.Join(dir, p.CoverPath) if runtime.GOOS == "windows" { - pdfg.Cover.Input = p.CoverPath + pdfg.Cover.Input = dir } else { - pdfg.Cover.Input = "file://" + p.CoverPath + pdfg.Cover.Input = "file://" + dir } }