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