This commit is contained in:
Mrx
2026-03-16 13:10:42 +08:00
parent 14b2c53eeb
commit 6f0a8e0519
3 changed files with 35 additions and 16 deletions

View File

@@ -1186,10 +1186,14 @@ func (pb *PageBuilder) drawRichTextBlock(pdf *gofpdf.Fpdf, text string, contentW
// getContentPreview 获取内容预览(用于日志记录)
func (pb *PageBuilder) getContentPreview(content string, maxLen int) string {
content = strings.TrimSpace(content)
if len(content) <= maxLen {
if maxLen <= 0 || len(content) <= maxLen {
return content
}
return content[:maxLen] + "..."
n := maxLen
if n > len(content) {
n = len(content)
}
return content[:n] + "..."
}
// wrapJSONLinesToWidth 将 JSON 文本按宽度换行,返回用于绘制的行列表(兼容中文等)