Merge remote-tracking branch 'origin/master'
This commit is contained in:
8
svc/.env
8
svc/.env
@@ -5,3 +5,11 @@ API_URL=http://localhost:8080
|
|||||||
UI_DIR=/opt/bssapp/ui/dist
|
UI_DIR=/opt/bssapp/ui/dist
|
||||||
POSTGRES_CONN=host=46.224.33.150 port=5432 user=postgres password=tayitkan dbname=baggib2b sslmode=disable
|
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
|
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
|
||||||
|
|||||||
@@ -9,11 +9,31 @@ import (
|
|||||||
"github.com/jung-kurt/gofpdf"
|
"github.com/jung-kurt/gofpdf"
|
||||||
)
|
)
|
||||||
|
|
||||||
func resolvePdfAssetPath(fileName string) (string, error) {
|
func resolvePdfAssetPath(file string) (string, error) {
|
||||||
return resolveAssetPath(fileName, []string{
|
|
||||||
"fonts",
|
envMap := map[string]string{
|
||||||
filepath.Join("svc", "fonts"),
|
"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) {
|
func resolvePdfImagePath(fileName string) (string, error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user