We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Text formatting is lost after adding cloned row to table using Java

Hi Aspose team.

I’m trying to clone a table row and add it to a table.
But the deep clone fails to clone the bold text.
We are using aspose words java lastest version.

Screen Shot 2019-12-26 at 15.36.57.png (50.4 KB)
As you can see in the image above, the second row is cloned from the first, all font properties are correctly cloned, but the BOLD not.
Is this a bug, or I am doing something wrong?

I’m using the following code, to clone and add the row to the table:
Row clonedRow = (Row) table.getLastRow().deepClone(true);
table.getRows().insert(table.getLastRow().getCount(), clonedRow);

This is urgent for us.

Kind regards,
Paulo Pereira

@pamp

To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document.
  • Please attach the output Word file that shows the undesired behavior.
  • Please create a simple Java 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.

Hi @tahir.manzoor,

Archive 2.zip (67.0 KB)
In the arquive the input and output document.
The code used is a simple row clone, as you can see here :

Document srcDoc = new Document(dataDir + “Template_not_working(1).docx”);

    Table table = srcDoc.getFirstSection().getBody().getTables().get(0);

    Row clonedRow = (Row) table.getLastRow().deepClone(true);
    table.getRows().insert(table.getLastRow().getCount(), clonedRow);
    srcDoc.save(dataDir + "TestFile Out.docx");  

Kind regards,
\Paulo Pereira

@pamp

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-19824. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Hi @tahir.manzoor,
Thank you for the feedback.

How can I track the issue WORDSNET-19824 ?

kind regards,
Paulo Pereira

@pamp

We try our best to deal with every customer request in a timely fashion, we unfortunately cannot guarantee a delivery date to every customer issue. We work on issues on a first come, first served basis. We feel this is the fairest and most appropriate way to satisfy the needs of the majority of our customers.

Currently, your issue is pending for analysis and is in the queue. Once we complete the analysis of your issue, we will then be able to provide you an estimate.

You reported this issue in free support forum and it will be treated with normal priority. To speed up the progress of issue’s resolution, we suggest you please check our paid support policies from following link.
Paid Support Policies

@pamp

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-19824) as ‘Not a Bug’.

In your document, there is special formatting for the first row - bold font. Actually, for the NON-bold strings bold is explicitly set to false. Font for the bold strings is ‘coming’ from the table style. Therefore after cloning bold strings became normal.

To avoid that it’s needed to modify table style (change/remove formatting for the first row and set font weight explicitly for the text in the table), or remove it at all if it’s possible. Please check the attached image for detail. table_style.png (37.6 KB)

Moreover, you can call Table.ExpandTableStylesToDirectFormatting() method before cloning the row to get the desired output.