1

我正在使用DOM方式从XHTML构建 Document 。如果没有DocumentBuilder方法,我将如何在页眉或页脚中添加页码?

4

1 回答 1

0

使用DOM,您可以使用 appendChild() 和 appendField() 方法在页眉/页脚中添加页码。下面是一个例子。

// Load your document
Aspose.Words.Document doc = new Aspose.Words.Document("document.docx");
// Get the primary footer
Aspose.Words.HeaderFooter hf = doc.FirstSection.HeadersFooters[HeaderFooterType.FooterPrimary];
// Get the first paragraph of footer
Aspose.Words.Paragraph para = hf.FirstParagraph;
// Add current page number field
para.AppendField("PAGE");
// Add a / character
para.AppendChild(new Run(doc, "/"));
// Add total page numbers field
para.AppendField("NUMPAGES");

我与 Aspose 一起担任开发人员布道师。

于 2015-03-24T05:46:28.247 回答