Merge remote-tracking branch 'origin/master'

This commit is contained in:
M_Kececi
2026-03-03 11:35:34 +03:00
parent 3a574bff6c
commit 4805216808
2 changed files with 24 additions and 10 deletions

View File

@@ -289,7 +289,7 @@ func drawCustomerBalancePDF(
}
wrappedLines := func(text string, w float64) [][]byte {
t := strings.TrimSpace(text)
t := strings.TrimSpace(sanitizePDFText(text))
if t == "" {
t = "-"
}
@@ -321,7 +321,7 @@ func drawCustomerBalancePDF(
cy := startY
for _, ln := range lines {
pdf.SetXY(x+1, cy)
pdf.CellFormat(w-2, lineH, string(ln), "", 0, align, false, 0, "")
pdf.CellFormat(w-2, lineH, sanitizePDFText(string(ln)), "", 0, align, false, 0, "")
cy += lineH
}
}
@@ -404,7 +404,7 @@ func drawCustomerBalancePDF(
drawWrapped(v, x, y, summaryW[i], rowH, 3.2, "L")
} else {
pdf.SetXY(x+1, y+(rowH-4.2)/2)
pdf.CellFormat(summaryW[i]-2, 4.2, v, "", 0, align, false, 0, "")
pdf.CellFormat(summaryW[i]-2, 4.2, sanitizePDFText(v), "", 0, align, false, 0, "")
}
x += summaryW[i]
}
@@ -491,7 +491,7 @@ func drawCustomerBalancePDF(
drawWrapped(v, rowX, rowY, detailW[i], rowH, 3.0, "L")
} else {
pdf.SetXY(rowX+1, rowY+(rowH-4.0)/2)
pdf.CellFormat(detailW[i]-2, 4.0, v, "", 0, align, false, 0, "")
pdf.CellFormat(detailW[i]-2, 4.0, sanitizePDFText(v), "", 0, align, false, 0, "")
}
rowX += detailW[i]
}
@@ -555,3 +555,17 @@ func absFloat(v float64) float64 {
}
return v
}
func sanitizePDFText(s string) string {
s = strings.ToValidUTF8(s, "?")
s = strings.ReplaceAll(s, "\x00", " ")
return strings.Map(func(r rune) rune {
if r == '\n' || r == '\r' || r == '\t' {
return ' '
}
if r < 32 {
return -1
}
return r
}, s)
}