Preserve Font & Size Formatting during Inserting Word Table into Another Document using Java - Keep Source Formatting

Hello,
I have outer document and try to insert a new Document with table content into this outer document.
But I have faced issue: both documents have font size = 11, but after inserting document according to this documentation https://docs.aspose.com/display/wordsjava/How+to++Insert+a+Document+into+another+Document#HowtoInsertaDocumentintoanotherDocument-InsertaDocumentatAnyLocation font size of inner document (with table) has been changed to 12 (???)

So I have:
Doc 1 (text with font size = 11)
Doc 2 (table with font size = 11)

Inserting Doc 2 into Doc 1 and get:
Doc 3 (text with font size = 11 + table with font size = 12)

When I try to force font size in table to e.g 10 , size is changing correctly:
for (Object runObject : table.getChildNodes(NodeType.RUN, true)) {
Run run = (Run)runObject;
Font font = run.getFont();
double currentSize = font.getSize();
font.setSize(10);
}

But even if I will try to force to font size in table to 11 - it is changing to 12 again.

Do you have any idea how can I handle this?
Please feel free contact me if you need any more details.

@wojkloc,

Please ZIP and upload your input Word documents and Aspose.Words generated output DOCX file showing the undesired behavior here for testing. Please also provide piece of source code that you are using to insert one Word document into another. We will then investigate the issue on our end and provide you more information.

Hi. Thanks for the feedback.
Full source code and Word file examples are available on:

You can find it also in the zip included:
asposeTest.zip (393.6 KB)

Please find it out and feel free contact me in case of any questions

@wojkloc,

You can observe this behavior when executing the following simple code:

Document outerDoc = new Document("E:\\Temp\\asposeTest\\outerDoc.docx");
Document innerDoc2 = new Document("E:\\Temp\\asposeTest\\innerDoc2.docx");

DocumentBuilder builder = new DocumentBuilder(outerDoc);
builder.moveToDocumentEnd();
builder.insertDocument(innerDoc2, ImportFormatMode.KEEP_SOURCE_FORMATTING);

outerDoc.save("E:\\Temp\\asposeTest\\awjava-20.1.docx");

Also, when you copy the target Table to ‘outerDoc.docx’ manually by using MS Word 2019, you will observe the same behavior. So, this seems to be an expected behavior. Please let us know if we can be of any further assistance.

@awais.hafeez,
yes it’s true, that simple code above will bring me the same result.
However please see attached screenshot:
wordBehavior.png (14.2 KB)

When I choose “Paste Options” -> Keep Source Formatting, then fonts in pasted table are changing to correct (size 11). I’m using Word 2016.
But it’s bit strange, because my code (and yours code) have ImportFormatMode.KEEP_SOURCE_FORMATTING flag.

What do you think, maybe downgrade to some prev version of library can help me? I will try to do some more tests with Word 2019 soon. I’ll let you know.

@wojkloc,

Thanks for the additional information. We have logged this problem in our issue tracking system. Your ticket number is WORDSNET-19927. We will further look into the details of this problem and will keep you updated on the status of the linked issue. We apologize for your inconvenience.

Thank you for attention to this matter. I cross my fingers and wish you good luck in investigation. Please let me know once find a solution or workaround.
Thanks in advance.

@awais.hafeez, thank you for your effort, I really appreciate.
What do you think, when we can expect any update on this ticket?
It would be nice to have High Level Estimation, just to adjust my own timelines. Would it be fays or months or quarters?
Thank you very much.

@wojkloc,

I am afraid, we are currently doing analysis of this issue to determine the root cause. There are no estimates available at the moment. Once the analysis of this issue will be completed, we may then be able to share the ETA of this issue with you. We apologize for your inconvenience.

@wojkloc,

Regarding WORDSNET-19927, it is to update you that if everything goes by plan, we are very hopeful to integrate the fix of this issue in the 20.3 (or in worst case scenario 20.4) version of Aspose.Words for Java. We will inform you via this thread as soon as a version containing the fix of your issue will be released in future. Thanks for your understanding and being patient.

The issues you have found earlier (filed as WORDSNET-19927) have been fixed in this Aspose.Words for .NET 20.3 update and this Aspose.Words for Java 20.3 update.

A post was split to a new topic: Preserve Font Formatting of Table Content while Inserting Inner Document to Outer Word Document C# or Java