Merge remote-tracking branch 'origin/master'

This commit is contained in:
2026-02-16 11:09:35 +03:00
parent 70f097806b
commit cd8c8a6e9e
2 changed files with 33 additions and 5 deletions

View File

@@ -5,3 +5,11 @@ API_URL=http://localhost:8080
UI_DIR=/opt/bssapp/ui/dist
POSTGRES_CONN=host=46.224.33.150 port=5432 user=postgres password=tayitkan dbname=baggib2b sslmode=disable
MSSQL_CONN=sqlserver://sa:Gil_0150@100.127.186.137:1433?database=BAGGI_V3&encrypt=disable
# ===============================
# PDF FONTS
# ===============================
PDF_FONT_PATH=/opt/bssapp/svc/fonts/DejaVuSans.ttf
PDF_FONT_BOLD_PATH=/opt/bssapp/svc/fonts/DejaVuSans-Bold.ttf
PDF_FONT_ALT_PATH=/opt/bssapp/svc/fonts/FreeSans.ttf
PDF_FONT_ALT_BOLD_PATH=/opt/bssapp/svc/fonts/FreeSansBold.ttf

View File

@@ -9,11 +9,31 @@ import (
"github.com/jung-kurt/gofpdf"
)
func resolvePdfAssetPath(fileName string) (string, error) {
return resolveAssetPath(fileName, []string{
"fonts",
filepath.Join("svc", "fonts"),
})
func resolvePdfAssetPath(file string) (string, error) {
envMap := map[string]string{
"DejaVuSans.ttf": "PDF_FONT_PATH",
"DejaVuSans-Bold.ttf": "PDF_FONT_BOLD_PATH",
"FreeSans.ttf": "PDF_FONT_ALT_PATH",
"FreeSansBold.ttf": "PDF_FONT_ALT_BOLD_PATH",
}
envKey, ok := envMap[file]
if !ok {
return "", fmt.Errorf("unknown font: %s", file)
}
path := os.Getenv(envKey)
if path == "" {
return "", fmt.Errorf("env %s not set", envKey)
}
if _, err := os.Stat(path); err != nil {
return "", fmt.Errorf("font not found: %s", path)
}
return path, nil
}
func resolvePdfImagePath(fileName string) (string, error) {