🎨 Add page number generation and refine the methodology

This commit is contained in:
landaiqing committed 2025-04-16 20:50:40 +08:00
1 parent 6b4be90900
commit 53a154a6df
8 files changed
+1150 -56

No files matched your search

+10 -5
View File
@@ -134,11 +134,16 @@ func main() {
// 添加页脚并同时添加页脚引用
footer := doc.AddFooterWithReference("default")
footerPara := footer.AddParagraph()
footerPara.SetAlignment("center")
footerPara.AddRun().AddText("第 ")
footerPara.AddRun().AddPageNumber()
footerPara.AddRun().AddText(" 页")
// 使用新的方法添加完整的页码段落
footer.AddPageNumber()
// 注释掉旧的方式,它可能会导致页码显示为"第PAGE页"
// footerPara := footer.AddParagraph()
// footerPara.SetAlignment("center")
// footerPara.AddRun().AddText("第 ")
// footerPara.AddRun().AddPageNumber()
// footerPara.AddRun().AddText(" 页")
// 保存文档
err := doc.Save("./document/examples/simple/example.docx")