This commit is contained in:
@@ -65,7 +65,7 @@ func (pb *PageBuilder) AddFirstPage(pdf *gofpdf.Fpdf, product *entities.Product,
|
||||
pb.addWatermark(pdf, chineseFontAvailable)
|
||||
|
||||
// 封面页布局 - 居中显示
|
||||
pageWidth, pageHeight := pdf.GetPageSize()
|
||||
pageWidth, _ := pdf.GetPageSize()
|
||||
|
||||
// 标题区域(页面中上部)
|
||||
pdf.SetY(80)
|
||||
@@ -128,14 +128,21 @@ func (pb *PageBuilder) AddFirstPage(pdf *gofpdf.Fpdf, product *entities.Product,
|
||||
}
|
||||
}
|
||||
|
||||
// 底部信息(价格等)
|
||||
// 价格信息(右下角,在产品详情之后)
|
||||
if !product.Price.IsZero() {
|
||||
pdf.SetY(pageHeight - 60)
|
||||
// 获取产品详情结束后的Y坐标,稍微下移显示价格
|
||||
contentEndY := pdf.GetY()
|
||||
pdf.SetY(contentEndY + 5)
|
||||
pdf.SetTextColor(0, 0, 0)
|
||||
pb.fontManager.SetFont(pdf, "", 12)
|
||||
_, lineHt = pdf.GetFontSize()
|
||||
pdf.CellFormat(0, lineHt, fmt.Sprintf("价格:%s 元", product.Price.String()), "", 1, "C", false, 0, "")
|
||||
pb.fontManager.SetFont(pdf, "", 14)
|
||||
_, priceLineHt := pdf.GetFontSize()
|
||||
priceText := fmt.Sprintf("价格:%s 元", product.Price.String())
|
||||
textWidth := pdf.GetStringWidth(priceText)
|
||||
// 右对齐:从页面宽度减去文本宽度和右边距(15mm)
|
||||
pdf.SetX(pageWidth - textWidth - 15)
|
||||
pdf.CellFormat(textWidth, priceLineHt, priceText, "", 0, "R", false, 0, "")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// AddDocumentationPages 添加接口文档页面
|
||||
|
||||
Reference in New Issue
Block a user