Pagebreak at wrong position

Hello,

I’ve created a simply document with nested tables and some pagebreaks. The first entry renders correctly, but on all the next entries, the last pagebreak moves bevore the first upper text line, either if MailMerge.CleanupOptions is set to nothing. This looks very ugly and I can’t repair this.
Can you, please, take a look what goes wrong?

Many thanks in advance!
Alexform_zba_248.zip (38.1 KB)

@Alex1974

Could you please attach the following resources here for testing:

  • Please attach the output Word file that shows the undesired behavior.
  • Please attach the expected output Word file that shows the desired behavior.
  • Please share the screenshots of problematic sections.
  • 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.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.

Hello Tahir,

I think, I got it, and this was really complicated. I’ll try to explain.
Our real word application makes MailMerge and renders a result, if user want, it can save a result. But the rendered results are wrong (you can reproduce that). After I create a simplified application for your investigation, the bug is gone - the saved docuemnt was corrent. That was really starnge, because I have used exactly same code, template and data. After hours of thinking I get the idea, that maybe the drawing without saving is the problem… But saved copy was also wrong. Then, in our real application I’ve saved document bevore drawing - it was also buggy. Now I get really crazy… Just now I see the difference WHICH FORMAT was used to save - docx vs. doc. That was an AHA-effect. Now, the test-application can save DOC and DOCX and they are really different results! Now I think, the internal Aspose-drawer (or paginater) uses something like “save docx” before drawing, and that produces strange result.

Test application attached (I need a licence-activation, without that it does not work either). You will see two buttons. Try and you will see the difference.

Thanks,
AlexWpfAsposeWords.zip (384.3 KB)

@Alex1974

We have tested the scenario using the latest version of Aspose.Words for .NET 19.7 and have not found any difference in DOC and DOCX output documents. So, please use Aspose.Words for .NET 19.7.

If you still face the same issue at your end, please ZIP and attach the screenshots of problematic sections of output document.

Sorry, but nope, the same thing with latest 19.7 version.
image.png (30.5 KB)

@Alex1974

We are investigating this issue and will share our findings with you soon.

@Alex1974

Please note that you can press Alt+F9 in Microsoft Word to toggle display of field codes on or off.

You are viewing the document with toggle display of field codes on. Please open the documents in MS Word and press Alt+F9 for both documents to make the display of code off. You will get the same output.

No, it is still the same!
And the real application DOES NOT SAVE a document at all, it does paginated drwaing, and this one hase exactly the same effect - the bold header is on top of first entry and at the end of all previous entries (instead be on top either).image.png (65.9 KB)

In the output I can exactly see what happens: the last PageBreak in template does not exists in the output document. That has the effect, next lines continue on the same page, and because this ist the end of a page, the following table starts on the next page. You should take a look, why a pagebreak is removed.

@Alex1974

In your case, we suggest you please set the property ‘page break before’ of first paragraph in your document to get the desired output. Please check the attached image for this property.

We have attached the modified document with this post for your kind reference. form_zba_248_Richterblatt_Wesensbeurteilung - modified.zip (28.0 KB)

Hello Tahir,

thank you, that works for this template.
But I assume, this can be only a temporarly workaround - what if some pagebreak in between will take effect, but following text lines will be skipped, because merge fields are empty - now we can get empty site.

Would you make a “real bugfix” latter? If yes. please let me know baout an update.

@Alex1974

Please note that this is not a workaround. This is another way to get the desired output. You can use it in your templates.

We have logged this problem in our issue tracking system as WORDSNET-18901. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

@Alex1974

Thanks for your patience. It is to inform you that the issue which you are facing is actually not a bug in Aspose.Words. So, we have closed this issue (WORDSNET-18901) as ‘Not a Bug’.

The template document has following mailmerge region hierarchy: Hundelist -> Hund -> Ergebnis. The problematic pagebreak is a part of Hundelist mailmerge region :

{ MERGEFIELD TableStart:Hundelist }{ MERGEFIELD TableStart:Hund }
{ MERGEFIELD TableStart:Ergebnis }
...
{ MERGEFIELD TableEnd:Ergebnis }{ MERGEFIELD TableEnd:Hund }
PAGEBREAK
{ MERGEFIELD TableEnd:Hundelist }

You should place page break at proper place (at the end of Hund or Ergebnis region) to achieve expected result.