Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -9,21 +9,21 @@ import (
|
|||||||
"github.com/jung-kurt/gofpdf"
|
"github.com/jung-kurt/gofpdf"
|
||||||
)
|
)
|
||||||
|
|
||||||
func resolvePdfAssetPath(name string) (string, error) {
|
func resolvePdfAssetPath(envKey string) (string, error) {
|
||||||
|
path := os.Getenv(envKey)
|
||||||
base := strings.TrimSpace(os.Getenv("PDF_FONT_DIR"))
|
if path == "" {
|
||||||
|
return "", fmt.Errorf("env %s not set", envKey)
|
||||||
if base == "" {
|
|
||||||
base = "/opt/bssapp/svc/fonts"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
p := filepath.Join(base, name)
|
if !filepath.IsAbs(path) {
|
||||||
|
return "", fmt.Errorf("font path must be absolute: %s", path)
|
||||||
if _, err := os.Stat(p); err != nil {
|
|
||||||
return "", fmt.Errorf("font not found: %s", p)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return p, nil
|
if _, err := os.Stat(path); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return path, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func resolvePdfImagePath(fileName string) (string, error) {
|
func resolvePdfImagePath(fileName string) (string, error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user