Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -9,7 +9,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -54,8 +53,6 @@ var hMainWbase = []float64{
|
|||||||
const (
|
const (
|
||||||
hFontFamilyReg = "dejavu"
|
hFontFamilyReg = "dejavu"
|
||||||
hFontFamilyBold = "dejavu-b"
|
hFontFamilyBold = "dejavu-b"
|
||||||
hFontPathReg = "fonts/DejaVuSans.ttf"
|
|
||||||
hFontPathBold = "fonts/DejaVuSans-Bold.ttf"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Renkler
|
// Renkler
|
||||||
@@ -66,13 +63,8 @@ var (
|
|||||||
|
|
||||||
/* ============================ FONT / FORMAT ============================ */
|
/* ============================ FONT / FORMAT ============================ */
|
||||||
|
|
||||||
func hEnsureFonts(pdf *gofpdf.Fpdf) {
|
func hEnsureFonts(pdf *gofpdf.Fpdf) error {
|
||||||
if _, err := os.Stat(hFontPathReg); err == nil {
|
return registerDejavuFonts(pdf, hFontFamilyReg, hFontFamilyBold)
|
||||||
pdf.AddUTF8Font(hFontFamilyReg, "", hFontPathReg)
|
|
||||||
}
|
|
||||||
if _, err := os.Stat(hFontPathBold); err == nil {
|
|
||||||
pdf.AddUTF8Font(hFontFamilyBold, "", hFontPathBold)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func hNormalizeWidths(base []float64, targetTotal float64) []float64 {
|
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 := gofpdf.New("L", "mm", "A4", "")
|
||||||
pdf.SetMargins(hMarginL, hMarginT, hMarginR)
|
pdf.SetMargins(hMarginL, hMarginT, hMarginR)
|
||||||
pdf.SetAutoPageBreak(false, hMarginB)
|
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
|
wAvail := hPageWidth - hMarginL - hMarginR
|
||||||
mainWn := hNormalizeWidths(hMainWbase, wAvail)
|
mainWn := hNormalizeWidths(hMainWbase, wAvail)
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -80,8 +79,6 @@ var dWbase = []float64{
|
|||||||
const (
|
const (
|
||||||
fontFamilyReg = "dejavu"
|
fontFamilyReg = "dejavu"
|
||||||
fontFamilyBold = "dejavu-b"
|
fontFamilyBold = "dejavu-b"
|
||||||
fontPathReg = "fonts/DejaVuSans.ttf"
|
|
||||||
fontPathBold = "fonts/DejaVuSans-Bold.ttf"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Kurumsal renkler
|
// Kurumsal renkler
|
||||||
@@ -134,17 +131,8 @@ func formatCurrencyTR(n float64) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fontları yükle
|
// Fontları yükle
|
||||||
func ensureFonts(pdf *gofpdf.Fpdf) {
|
func ensureFonts(pdf *gofpdf.Fpdf) error {
|
||||||
if _, err := os.Stat(fontPathReg); err == nil {
|
return registerDejavuFonts(pdf, fontFamilyReg, fontFamilyBold)
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Güvenli satır kırma
|
// Güvenli satır kırma
|
||||||
@@ -513,7 +501,10 @@ func ExportPDFHandler(mssql *sql.DB) http.HandlerFunc {
|
|||||||
pdf := gofpdf.New("L", "mm", "A4", "")
|
pdf := gofpdf.New("L", "mm", "A4", "")
|
||||||
pdf.SetMargins(marginL, marginT, marginR)
|
pdf.SetMargins(marginL, marginT, marginR)
|
||||||
pdf.SetAutoPageBreak(false, marginB)
|
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.SetFont(fontFamilyReg, "", 8.5)
|
||||||
pdf.SetTextColor(0, 0, 0)
|
pdf.SetTextColor(0, 0, 0)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user