证书生成

This commit is contained in:
马梓彭 2026-04-22 07:57:59 +08:00
parent 66a93af122
commit 8b8421a16b

View File

@ -1338,9 +1338,11 @@ public class CertificateGenerateService : IDynamicApiController, ITransient
.FitArea(); .FitArea();
} }
// 使用绝对定位来放置文本内容(更精确) // 使用 Column 来放置所有内容,但禁用默认间距
page.Content().Layer(layer => page.Content().Column(column =>
{ {
column.Spacing(0);
double? firstParagraphY = null; double? firstParagraphY = null;
double? firstParagraphOriginalY = null; double? firstParagraphOriginalY = null;
@ -1375,11 +1377,8 @@ public class CertificateGenerateService : IDynamicApiController, ITransient
_logger.LogDebug("段落 {Index} 位置: X={X}, Y={Y}", i + 1, x, y); _logger.LogDebug("段落 {Index} 位置: X={X}, Y={Y}", i + 1, x, y);
// 使用绝对定位放置文本 // 使用 Translate 来定位,配合 Spacing(0) 确保没有额外间隔
var textElement = layer var textElement = column.Item().TranslateX(x).TranslateY(y).Text(paragraph.Text)
.TranslateX(x)
.TranslateY(y)
.Text(paragraph.Text)
.FontSize((float)fontSize) .FontSize((float)fontSize)
.FontColor(QuestPDF.Helpers.Colors.Black) .FontColor(QuestPDF.Helpers.Colors.Black)
.AlignLeft(); .AlignLeft();