From 6d22f5874a07f0245def6ebdd36b9066c8389c3f Mon Sep 17 00:00:00 2001 From: MEHMETKECECI Date: Sat, 14 Feb 2026 16:44:36 +0300 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- svc/routes/statement_header_pdf.go | 17 ++++++----------- svc/routes/statements_pdf.go | 21 ++++++--------------- 2 files changed, 12 insertions(+), 26 deletions(-) diff --git a/svc/routes/statement_header_pdf.go b/svc/routes/statement_header_pdf.go index 85834f1..4046899 100644 --- a/svc/routes/statement_header_pdf.go +++ b/svc/routes/statement_header_pdf.go @@ -9,7 +9,6 @@ import ( "fmt" "log" "net/http" - "os" "path/filepath" "sort" "strings" @@ -54,8 +53,6 @@ var hMainWbase = []float64{ const ( hFontFamilyReg = "dejavu" hFontFamilyBold = "dejavu-b" - hFontPathReg = "fonts/DejaVuSans.ttf" - hFontPathBold = "fonts/DejaVuSans-Bold.ttf" ) // Renkler @@ -66,13 +63,8 @@ var ( /* ============================ FONT / FORMAT ============================ */ -func hEnsureFonts(pdf *gofpdf.Fpdf) { - if _, err := os.Stat(hFontPathReg); err == nil { - pdf.AddUTF8Font(hFontFamilyReg, "", hFontPathReg) - } - if _, err := os.Stat(hFontPathBold); err == nil { - pdf.AddUTF8Font(hFontFamilyBold, "", hFontPathBold) - } +func hEnsureFonts(pdf *gofpdf.Fpdf) error { + return registerDejavuFonts(pdf, hFontFamilyReg, hFontFamilyBold) } func hNormalizeWidths(base []float64, targetTotal float64) []float64 { @@ -332,7 +324,10 @@ func ExportStatementHeaderReportPDFHandler(mssql *sql.DB) http.HandlerFunc { pdf := gofpdf.New("L", "mm", "A4", "") pdf.SetMargins(hMarginL, hMarginT, hMarginR) pdf.SetAutoPageBreak(false, hMarginB) - hEnsureFonts(pdf) + if err := hEnsureFonts(pdf); err != nil { + http.Error(w, "PDF font yükleme hatası: "+err.Error(), http.StatusInternalServerError) + return + } wAvail := hPageWidth - hMarginL - hMarginR mainWn := hNormalizeWidths(hMainWbase, wAvail) diff --git a/svc/routes/statements_pdf.go b/svc/routes/statements_pdf.go index 9908fa7..42b28f3 100644 --- a/svc/routes/statements_pdf.go +++ b/svc/routes/statements_pdf.go @@ -10,7 +10,6 @@ import ( "fmt" "log" "net/http" - "os" "path/filepath" "sort" "strings" @@ -80,8 +79,6 @@ var dWbase = []float64{ const ( fontFamilyReg = "dejavu" fontFamilyBold = "dejavu-b" - fontPathReg = "fonts/DejaVuSans.ttf" - fontPathBold = "fonts/DejaVuSans-Bold.ttf" ) // Kurumsal renkler @@ -134,17 +131,8 @@ func formatCurrencyTR(n float64) string { } // Fontları yükle -func ensureFonts(pdf *gofpdf.Fpdf) { - if _, err := os.Stat(fontPathReg); err == nil { - pdf.AddUTF8Font(fontFamilyReg, "", fontPathReg) - } else { - log.Printf("⚠️ Font bulunamadı: %s", fontPathReg) - } - if _, err := os.Stat(fontPathBold); err == nil { - pdf.AddUTF8Font(fontFamilyBold, "", fontPathBold) - } else { - log.Printf("⚠️ Font bulunamadı: %s", fontPathBold) - } +func ensureFonts(pdf *gofpdf.Fpdf) error { + return registerDejavuFonts(pdf, fontFamilyReg, fontFamilyBold) } // Güvenli satır kırma @@ -513,7 +501,10 @@ func ExportPDFHandler(mssql *sql.DB) http.HandlerFunc { pdf := gofpdf.New("L", "mm", "A4", "") pdf.SetMargins(marginL, marginT, marginR) pdf.SetAutoPageBreak(false, marginB) - ensureFonts(pdf) + if err := ensureFonts(pdf); err != nil { + http.Error(w, "PDF font yükleme hatası: "+err.Error(), http.StatusInternalServerError) + return + } pdf.SetFont(fontFamilyReg, "", 8.5) pdf.SetTextColor(0, 0, 0)