Merge remote-tracking branch 'origin/master'

This commit is contained in:
M_Kececi
2026-03-17 11:23:20 +03:00
parent ba8c1dd801
commit 06af84204a

View File

@@ -311,6 +311,9 @@ func drawCustomerBalancePDF(
y := pdf.GetY()
x := marginL
for i, c := range summaryCols {
if i >= len(summaryW) {
break
}
pdf.Rect(x, y, summaryW[i], 7, "DF")
pdf.SetXY(x+1, y+1.2)
pdf.CellFormat(summaryW[i]-2, 4.6, c, "", 0, "C", false, 0, "")
@@ -326,6 +329,9 @@ func drawCustomerBalancePDF(
y := pdf.GetY()
x := marginL
for i, c := range detailCols {
if i >= len(detailW) {
break
}
pdf.Rect(x, y, detailW[i], 6, "DF")
pdf.SetXY(x+1, y+1)
pdf.CellFormat(detailW[i]-2, 4, c, "", 0, "C", false, 0, "")
@@ -569,7 +575,7 @@ func calcPDFRowHeight(pdf *gofpdf.Fpdf, row []string, widths []float64, wrapIdx
if i >= len(widths) || widths[i] <= 2 {
continue
}
lines := pdf.SplitLines([]byte(strings.TrimSpace(v)), widths[i]-2)
lines := safeSplitLinesPDF(pdf, strings.TrimSpace(v), widths[i]-2)
if len(lines) > maxLines {
maxLines = len(lines)
}
@@ -586,7 +592,7 @@ func drawPDFCellWrapped(pdf *gofpdf.Fpdf, value string, x, y, w, h float64, alig
return
}
text := strings.TrimSpace(value)
lines := pdf.SplitLines([]byte(text), w-2)
lines := safeSplitLinesPDF(pdf, text, w-2)
if len(lines) == 0 {
lines = [][]byte{[]byte("")}
}
@@ -603,6 +609,19 @@ func drawPDFCellWrapped(pdf *gofpdf.Fpdf, value string, x, y, w, h float64, alig
}
}
func safeSplitLinesPDF(pdf *gofpdf.Fpdf, text string, width float64) (lines [][]byte) {
if width <= 0 {
width = 1
}
defer func() {
if recover() != nil {
lines = [][]byte{[]byte(text)}
}
}()
lines = pdf.SplitLines([]byte(text), width)
return lines
}
func formatCurrencyMapPDF(m map[string]float64) string {
if len(m) == 0 {
return "-"