On Coverting Word to PDF - Page Numbering issue at Footer

on Coverting from Word to PDF, Example - Imagine a word Document having 3 pages,
Now on merging 2 different word documents, and convert the merged document to PDF. If you look at the footer of merged word document(one with 3 pages word document), footer page numbering will be shown wrong as Page 3 of 3 on all three pages of converted PDF. Could you please help me out on this issue asap?

Kindly please let know , if u need more details
email me at a.mani.kumar03@gmail.com

Cheers,
Manikumar A

@Manikumar1709

Thanks for your inquiry. Please ZIP and attach your input Word documents here for testing. We will investigate the issue on our side and provide you more information.

@tahir.manzoor
Testdata.pdf (50.0 KB)
If u look at the PDF attachment, there will be 6 Pages. first 3 page are one word document and next 3 pages were another word document. We will merge those two documents using aspose. On merging those two documents, if u look at page 4 footer(Page Starts with content ASRS-R ), it will be page 3 of 3. Actually we need it to be like Page 1 of 3, Page 2 of 3, Page 3 of 3. but we are getting as for all pages Page 3 of 3. Could you please help me out on this issue ASAP?

Thanks,

Regards,
Manikumar

@tahir.manzoor

Code:
public Stream AppendWordDocument(Stream parentDoc, Stream childDoc, bool IsNewPage, bool UnLinkPageNumber = false)
{
var parent = GetWordDocument(parentDoc);
var child = GetWordDocument(childDoc);
parent.UpdatePageLayout();
child.FirstSection.PageSetup.SectionStart = IsNewPage ? SectionStart.NewPage : SectionStart.Continuous;
child.FirstSection.PageSetup.PageWidth = parent.LastSection.PageSetup.PageWidth;
child.FirstSection.PageSetup.PageHeight = parent.LastSection.PageSetup.PageHeight;
child.FirstSection.PageSetup.Orientation = parent.LastSection.PageSetup.Orientation;

        if (UnLinkPageNumber)
        {
            child.UpdatePageLayout();
            UnlinkFields(child, new FieldType[] { FieldType.FieldNumPages, FieldType.FieldPage });
            parent.UpdatePageLayout();
            UnlinkFields(parent, new FieldType[] { FieldType.FieldNumPages });
        }
        parent.AppendDocument(child, ImportFormatMode.KeepSourceFormatting);
        parent.UpdatePageLayout();
        return GetDocumentAsMemoryStream(parent, DocumentType.WORD);
    }

@Manikumar1709

Thanks for your inquiry. Unfortunately, It is difficult to say what the problem is without your input Word documents. Please share your documents for investigation.

test.zip (31.9 KB)

@tahir.manzoor
PFA for word documents. These were two documents which we merge.

@Manikumar1709

Thanks for sharing the detail. We have tested the scenario using the latest version of Aspose.Words for .NET 18.10 and have not found the shared issue.

You are facing this issue because you are unlinking the PAGE and NUMPAGES field. The Field.Unlink method replaces the field with its most recent result. To get the desired output, please do not call this method.

To restart the page number at the beginning of the section, please use PageSetup.RestartPageNumbering property as shown below. Please also replace the NUMPAGES field with SECTIONPAGES field in your document.

parent.AppendDocument(child, ImportFormatMode.KeepSourceFormatting);
parent.FirstSection.PageSetup.RestartPageNumbering = true;
parent.UpdatePageLayout();
                  
parent.Save(MyDir + "18.10.pdf");

@tahir.manzoor,

Thanks so much for the Query. We are not using as now latest version of Aspose.

Could you please advice and share query for below issues,
I have One Parent Document, two Child Document. On merging two Child Document, Page numbering should be Continuous as like Page 1 of 5, Page 2 of 5, Page 3 of 5,etc… if total Pages of Child documents is 5. But in my Case, Page showing for first Child Document as Page 3 of 3 for all first Child Document, and for Second child document its showing like Page 5 of 5 for both Pages.

Kindly please look into the attachment, I have shared the Parent Document and Two Child Document, also merged Pdf document.test.zip (110.5 KB)

@Manikumar1709

Thanks for your inquiry. You are saving your final PDF document using Aspose.PDF. If you join the documents and do not use UnlinkFields method, you will get the correct output.

If you still face the problem, please create a standalone console application ( source code without compilation errors ) that helps us to reproduce your problem on our end and attach it here for testing.

We will investigate the issue and provide you more information on it. Thanks for your cooperation.