We have merged multiple documents into one using bookmark and we now like to reset the page number to start from #1 for each page that starts where there is a specific bookmark.
We have merged multiple documents into one using bookmark and we now like to reset the page number to start from #1 for each page that starts where there is a specific bookmark.
Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Thanks for your request. You can use RestartPageNumbering. Please see the following code:
//Open document and create DocumentBuilder
Document doc = new Document(@"Test004\in.doc");
DocumentBuilder builder = new DocumentBuilder(doc);
//move documentBuilder cursor to the bookmark
builder.MoveToBookmark("mybk");
//Insert section break
builder.InsertBreak(BreakType.SectionBreakContinuous);
//restart page numbering
builder.CurrentSection.PageSetup.RestartPageNumbering = true;
//Save output document
doc.Save(@"Test004\out.doc");
If your bookmark is placed at the beginning of the section then you can remove highlighted line from the code.
Hope this helps.
Best regards.