在我的Word文档中,我添加了新的部分:
var defaultSection = mainPart.Document.Descendants<SectionProperties>().First();
var paragraph2 = new Paragraph();
var paragraphProperties2 = new ParagraphProperties();
var sectionProperties2 = defaultSection.Clone() as SectionProperties;
var sectionTypeCur = sectionProperties2.Descendants<SectionType>().FirstOrDefault();
sectionProperties2.RemoveChild(sectionTypeCur);
var sectionType2 = new SectionType() { Val = SectionMarkValues.NextPage };
var pageNumberType2 = new PageNumberType()
{
ChapterSeparator = defaultPageNumbering.ChapterSeparator,
ChapterStyle = defaultPageNumbering.ChapterStyle,
Format = defaultPageNumbering.Format,
Start = null
};
var pageNumberTypeCur = sectionProperties2.Descendants<PageNumberType>().FirstOrDefault();
sectionProperties2.RemoveChild(pageNumberTypeCur);
sectionProperties2.Append(pageNumberType2);
var titlePageCur2 = sectionProperties2.Descendants<TitlePage>().FirstOrDefault();
sectionProperties2.RemoveChild(titlePageCur2);
paragraphProperties2.Append(sectionProperties2);
paragraph2.Append(paragraphProperties2);
lastElementInFirstSection.InsertAfterSelf(paragraph2);
并且在新版块中看到页码编号从默认值开始。但我想从上一节中的最高页码继续编号 我该怎么办?
答案 0 :(得分:0)
您需要使用SectionMarkValues.Continuous
代替Val = SectionMarkValues.NextPage
。连续没有进入下一页,所以你可能也需要进行简单的下一页休息。