如何在Word文档中重新启动页码

本文关键字:重新启动 文档 Word | 更新日期: 2023-09-27 18:37:04

>我有一个Word文档,从第二页开始页面喃喃自语。它看起来像:

first page - <no number>
second page - 3
third page -4
etc...

现在我想重新开始页码编号以:

first page - <no number>
second page - 6
third page -7
etc...

我试过这个答案

的意思是我只是在我的文档中放了一个新Paragraph。这是工作,但MS Word打开文档有错误。

在我尝试在Footer中放置一个新Paragraph之后:

string headerID = @"{ PAGE '* MERGEFORMAT }";
var footer = mainPart.FooterParts.First().Footer;
var paragraphtest = new Paragraph(
    new ParagraphProperties(
        new SectionProperties(
            new FooterReference {Id = headerID},
            new PageNumberType {Start = 10}
         )
     )
 );
footer.Append(paragraphtest);

但是现在文档只是没有打开。
如何正确地重新开始页码编号?

如何在Word文档中重新启动页码

哦,

对不起,伙计们,这是一个愚蠢的问题。十分钟后,我找到了解决方案。只需要获取文档中的第一个SectionProperties元素并设置页码起始值:

var firstSection=  mainPart.Document.Body.Elements<SectionProperties>().First();
firstSection.Append(new PageNumberType { Start = 10 });