Page break in different place

Aspose Version: 14.9
Issue Description:
When merge the field with value define in xml integrate into the word template.
Following are the outcome of the word document:
Expected Behavior: Paragraph should move to next page.
Actual Behavior: Paragraph break in same page.

Hi Basnayee,

Thanks for your inquiry. I have tested the scenario using following code example and have not found the shared issue. The output is same as ExceptedOutput.doc. I have attached the output document with this post for your kind reference.

Please make sure that you are using the latest version of Aspose.Words for .NET 14.9.0. If you still face problem, please create a standalone/runnable simple application (for example a Console Application Project) that demonstrates the code you used to generate your output document along with following detail.

  • What environment are you running on?
  • OS (Windows Version or Linux Version)
  • Architecture (32 / 64 bit)
  • .NET Framework version
Document doc = new Document(MyDir + "Test.doc");
DataSet ds = new DataSet();
ds.ReadXml(MyDir + "Test.xml");
doc.MailMerge.Execute(ds.Tables[0]);
doc.Save(MyDir + "Out.doc");

Hi Tahir,

To give some background couple of months back we have reported one issue and solution provided by aspose to introduce following code:

doc.MailMerge.CleanupOptions = MailMergeCleanupOptions.RemoveContainingFields;

Which fixed our old issue.But the same line of code is causing problem in current scenario.
Out come of the document is displaying in different format for same template(Before and after introduce above line of code). we have to make it work with same code so that old issue should not occur again.I have attached the sample project.

Regards,
Basnayee

Hi Basnayee,

Thanks for sharing the detail. You are facing the expected behavior of Aspose.Words. I suggest you please read the detail of MailMergeCleanupOptions from here:
https://reference.aspose.com/words/net/aspose.words.mailmerging/mailmergecleanupoptions/

Please open your document in MS Word and press Alt + F9 to check the IF field. MailMergeCleanupOptions.RemoveContainingFields specifies whether fields that contain merge fields (for example, IFs) should be removed from the document if the nested merge fields are removed.

If you use this cleanup option, the IF fields will be removed from output document and the paragraph at second page will move up to the first page. The is the expected behavior. Hope this answers your query.

Could you please share some detail about your old issue along with code and documents? We will check your scenario and provide you more information about your query.

Hi,

You can refer to (Mail Merge field values not retaining changed value in print preview) where we raised regarding old issue.

Ihave attached the sample project,Template and Merge document out.

after the merge document generate if user will do any modification while print preview it is not getting updated.

To fix this issue Aspose support team suggested to add following line of code:

doc.MailMerge.CleanupOptions = MailMergeCleanupOptions.RemoveContainingFields;

Hi Basnayee,

Thanks for sharing the
detail.

*Basnayee:

You can refer to (Mail Merge field values not retaining changed value in print preview) where we raised regarding old issue.
Ihave attached the sample project,Template and Merge document out.
after the merge document generate if user will do any modification while print preview it is not getting updated.
To fix this issue Aspose support team suggested to add following line of code:
doc.MailMerge.CleanupOptions = MailMergeCleanupOptions.RemoveContainingFields;*

Yes, in this case, you need to MailMerge CleanupOptions as MailMergeCleanupOptions.RemoveContainingFields to fix this issue.

Regarding your query reported in this thread, please note that Word
document is flow document and does not contain any information about
its layout into lines and pages. Therefore, technically there is no
“Page” concept in Word document. Pages are created by Microsoft Word on the fly.

You are facing the expected behavior of Aspose.Words. This is not an issue. If you manually remove some paragraphs from first page, the contents of second page move up to the first page.

In your scenario, I suggest you please insert the page break at the end of first page so that contents of second page do not move to first page of your document. Hope this helps you.