证书生成

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();
}
// 使用绝对定位来放置文本内容(更精确)
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();