Merge remote-tracking branch 'origin/master'

This commit is contained in:
2026-02-14 16:44:36 +03:00
parent 6105be3eb3
commit 6d22f5874a
2 changed files with 12 additions and 26 deletions

View File

@@ -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)