【问题标题】:How to add page number in Aspose Words for .NET without using DocumentBuilder?如何在不使用 DocumentBuilder 的情况下在 Aspose Words for .NET 中添加页码?
【发布时间】:2015-03-24 13:46:28
【问题描述】:

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

【问题讨论】:

    标签: aspose.words


    【解决方案1】:

    使用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 合作,担任开发人员宣传员。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多