Setting preferred width to 100% and autofit to false cause performance issue

Hi Team,

I tested on Aspose.WordsForJava 13.5 and 14.4.1.

I’m writing 1000 rows to a table. Setting preferred width to 100% and auto fit to false on a table causes performance problem. It takes 13 seconds to generate word/pdf document.
If I set autofit to true, the word/pdf generation completes in 1 second.

table.setPreferredWidth(PreferredWidth.fromPercent(100));
table.setAllowAutoFit(false);

Thanks,
Kumar

private static void createTable(DocumentBuilder docBuilder) throws Exception
{
docBuilder.getCellFormat().getBorders().setLineStyle(1);
docBuilder.getCellFormat().getBorders().setColor(Color.black);
docBuilder.getCellFormat().getBorders().setLineWidth(1);

Table table = docBuilder.startTable();

int rowCount = 1000;
int cellCount = 1;
for (int i = 0; i < rowCount; i++)
{
docBuilder.getRowFormat().setHeight(0);
for (int j = 0; j < cellCount; j++)
{
docBuilder.insertCell();
docBuilder.write(“one”);
}
docBuilder.endRow();
}

docBuilder.endTable();

table.setPreferredWidth(PreferredWidth.fromPercent(100));
table.setAllowAutoFit(false);
}

Hi Kumar,

Thanks for your inquiry. I have tested the scenario at Windows Server 2008 R2 with IMB and Sun JDK. I have not found the shared issue using latest version of Aspose.Words for Java 14.4.1.

Could you please try again the same scenario at your end? If you still face problem, please share your environment detail at which you tested this scenario. I will investigate the issue at same environment on my side and provide you more information.

Hi Tahir,

I’m to replicate the issue on on latest Aspose version as well.

Environment: Windows 7 OS, IBM 1.6 JRE

Aspose product and version is = Aspose.Words for Java : 14.4.1.0
Total time taken is: 13 seconds
table.setPreferredWidth(PreferredWidth.fromPercent(100));
table.setAllowAutoFit(false);

Aspose product and version is = Aspose.Words for Java : 14.4.1.0
Total time taken is: 1 seconds
table.setPreferredWidth(PreferredWidth.fromPercent(100));
table.setAllowAutoFit(true);

Please share your results.

Thanks,
Kumar

Hi Kumar,

Thanks for sharing the detail.

I have tested the same scenario using latest version of Aspose.Words for Java 14.4.1 at Windows 7 with IBM 1.6 JRE. I have not found the shared issue. Using Table.setAllowAutoFit(false), it takes zero second at my side. Please check the attached image for detail.

Hi Tahir,

Could you verify that both the documents are matching? Coz, if you’re not using any license, the output will be truncated and hence the results with faster execution.

Thanks,
Kumar

Hi Kumar,

Thanks for your inquiry. I am using the license to test this scenario. I am using following code example to test the shared scenario. Please let us know if you are not using the same code.


long t1 = System.currentTimeMillis();

DocumentBuilder docBuilder = new DocumentBuilder();

docBuilder.getCellFormat().getBorders().setLineStyle(1);

docBuilder.getCellFormat().getBorders().setColor(Color.black);

docBuilder.getCellFormat().getBorders().setLineWidth(1);

Table table = docBuilder.startTable();

int rowCount = 1000;

int cellCount = 1;

for (int i = 0; i < rowCount; i++)

{

docBuilder.getRowFormat().setHeight(0);

for (int j = 0; j < cellCount; j++)

{

docBuilder.insertCell();

docBuilder.write("one");

}

docBuilder.endRow();

}

docBuilder.endTable();

table.setPreferredWidth(PreferredWidth.fromPercent(100));

table.setAllowAutoFit(false);

long t2 = System.currentTimeMillis();

System.out.println("Execution time: " + (t2 - t1)/1000 + " seconds.");


Hi Tahir,

You need to include document save time in the overall time taken. The issue is during save.

Thanks,
Kmar

Hi Kumar,

Thanks for sharing the detail. I have tested the scenario and have found that Table.setAllowAutoFit(false) takes more time as compared to Table.setAllowAutoFit(true). When Table.setAllowAutoFit(false) is used, it takes 5 seconds.

For the sake of correction, I have logged this problem in our issue tracking system as WORDSJAVA-898. I have linked this forum thread to the same issue and you will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

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


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

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan