Aspose Words Remove Blank Page does not ReNumber the Pages

Hello support.
Just want to say, your support is AWESOME and quick.
Thank you so much :slight_smile:

Please see attached vs2019 project with sample files.

My company purchased the Aspose.Total.NET enterprise license.
We are using the Aspose.Words v21.4.0 (The most current as of this email).

I am trying to remove a blank page from the sample ms word docx file.

The blank page code seems to be working, but the Auto Page Number in the Header
does not get updated, and therefore the final generated PDF does not show the page numbers correctly.BlankPagePOC.zip (734.4 KB)

@tony.woods.bell.ca You can reset PageSetup.RestartPageNumbering property to make the numbering continue:

for (int i = 1; i < emptyPageNumbers.Count; i++)
{
    int index = (int)emptyPageNumbers[i - 1] + 1;
    int count = (int)emptyPageNumbers[i] - index;

    if (count > 0)
    {
        Document page = doc.ExtractPages(index, count);
        page.FirstSection.PageSetup.RestartPageNumbering = false;
        final_Document.AppendDocument(page, ImportFormatMode.KeepSourceFormatting);
    }
}

Thank you Alexey
I will try it and let you know.

1 Like