Skip to content

Commit

Permalink
🐛 gen pdf
Browse files Browse the repository at this point in the history
  • Loading branch information
yann0917 committed Jan 13, 2024
1 parent a9bd5b6 commit 852153e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions utils/genPdf.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"fmt"
"os"
"path/filepath"
"runtime"

"github.com/SebastiaanKlippert/go-wkhtmltopdf"
Expand All @@ -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
}
}

Expand Down

0 comments on commit 852153e

Please sign in to comment.