Consecutive tables joined incorrectly if page numbering is used

Hi,

I have 2 documents, noPageNumber.doc and withPageNumber.doc. They both contain 2 tables and one merge field in between. The tables have different number of columns.
The only difference between those documents is that withPageNumber.doc contains page number in the footer.

For each of those documents I do the following:

  1. Tell MailMerge to remove empty paragraphs on cleanup
  2. Call MailMerge.execute with empty string as value for the merge field.

What I expect is, that the merge field and its paragraph will be deleted and both tables joined together into one, preserving original widths of the columns.

This works with noPageNumber.doc (see noPageNumber_out.doc), but not with withPageNumber.doc: there the widths of columns are aligned (see withPageNumber_out.doc)

You can find the code and documents in the attachment. I tested it with the newest version of Aspose, that is 16.4.0. The code requires Java 7.

I wonder, what influence can PAGE and NUMPAGES-fields have on the way the tables are joined together? In debugger there is nothing to see, because of code obfuscation. It worked well with Aspose version 10.0.0-BETA.

Thanks,
Krzysztof

Hi Krzysztof,

Thanks for your inquiry. We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-13575. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Hi Tahir,
thank you for your answer. Is there any setting or workaround, that I could use to overcome this issue?

Hi Krzysztof,

Thanks for your inquiry. Please use following highlighted code snippet to workaround this issue. Hope this helps you.

Document doc = new Document(MyDir + "withPageNumber.doc");
doc.getMailMerge().setCleanupOptions(MailMergeCleanupOptions.REMOVE_EMPTY_PARAGRAPHS);
doc.getMailMerge().execute(new String[] {"to-remove"}, new Object[] {""});
Table table = (Table)doc.getChild(NodeType.TABLE, 0, true);
table.autoFit(AutoFitBehavior.FIXED_COLUMN_WIDTHS);
doc.save(MyDir + "Out.doc");

Hi Tahir,

thank you for the workaround - it works very well, also for our production documents with many tables - I just set the autoFit-property on all of them. I have a few questions:

  1. Is there any way to set this property globally, or do I really need to iterate all the tables in the document?
  2. Can I change somehow only the documents, without changes to the source code? My problem is, that we use aspose-words in the version 15.10.0 and it seems too risky to upgrade the library one major version up, without extensive testing. In the version we currently use, your fix does not work.
  3. Is it a bug and will it be fixed in a future version of aspose-words?

Hi Krzysztof,

Thanks for your inquiry. Please note that calling Table.autoFit method is a workaround of issue WORDSNET-13575. Your input document contains tables with auto fit behavior as fixed column width. If you are merging tables having auto fit behavior as fixed column width, you can call Table.autoFit(AutoFitBehavior.FIXED_COLUMN_WIDTHS) to fix this issue. This method re-calculate the table structure from the specified widths.

If you want to call Table.autoFit method for each table of document, you need to iterate through all tables of document and call this method for each table.

Currently WORDSNET-13575 is pending for analysis. Once our product team completes the analysis of this issue, we will then provide you more information about this issue.

Hi,
I see that the status of WORDSNET-13575 is now resolved. When will it be released?
Best regards,
Krzysztof Witukiewicz

Hi Krzysztof,

Thanks for your inquiry. Hopefully, the next version of Aspose.Words v16.7.0 will be published in couple of weeks. We will inform you via this forum thread once new version of Aspose.Words is released.

Thanks for your patience.

The issues you have found earlier (filed as WORDSNET-13575) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.