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