Alternative solution for Table Autofit property

Hi,
I have an aspose word document generated from HTML text. In that one cell is having colspan and contains lengthy and continuous line of asterisks(*). This causes the table to stretch out of the window.
I found the solution on Aspose forums by setting AllowAutoFit=false. I am using old version of Aspose. So this property is not available there. Any alternative to this?
Thank you for your help in advance!

Hi Hetal,

Thanks for your inquiry. First of all, we always encourage our customers to use the latest release versions of Aspose.Words as it contains newly introduced features, enhancements and fixes for issues reported earlier. I would suggest you please download/use the latest version (11.9.0) from the following link:
https://releases.aspose.com/words/net

Could you please attach your input Word document here for testing? I will investigate the issue on my side and provide you more information.

Thank you for your response.
I downloaded DLLs for version 11.8.0 and tried to genereate the word document by replacing the DLLs. But now it gives me following error for license:
“The subscription included in this license allows free upgrades until 05 Dec 2009…”
Should I purchase license for that?
Also please find the attachment which includes html file to generate word doc. Please analyse that and provide your feedback.
Thank you.

Hi Hetal,

Thanks for your inquiry and sharing the HTML file. Please use the following code snippet to achieve your required output document.

Document doc = new Document(MyDir +"HTMLText.html");
foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
{
    table.AutoFit(AutoFitBehavior.AutoFitToContents);
}
doc.Save(MyDir + "AsposeOut.docx");

Regarding subscription issue, please check the expiration date of your license file. To check an expiration date of your license open the license file using notepad. You will see the following tags:

20120218

It means that you can free upgrade to version of Aspose.Words published before 02/18/2012. If your license is not expired, please post your query in Aspose.Purchase forum.

If you need to update to the latest version of Aspose.Words, but your license does not allow you to update to this version, you should contact Aspose sales team to renew your license.
https://forum.aspose.com/c/purchase/6

hi,
the above works fine with the HTML file to Word but what if i dont have the html file and i have only html string and in that there is a table and how can i autofit it?

DocumentBuilder builder = new DocumentBuilder();

builder.InsertHtml(File.ReadAllText(@"C:\Users\ingyadav\Desktop\audit report.html").ToString());

foreach (Aspose.Words.Tables.Table table in builder.Document.GetChildNodes(NodeType.Table, true))
{
     table.AutoFit(Aspose.Words.Tables.AutoFitBehavior.AutoFitToContents);
}

tried with this and the autofit property is not applied

can anyone please help me on this?

aggovardhan005:
hi,
the above code snippet works fine with the HTML file to Word but what if i dont have the html file and i have only html string and in that there is a table and how can i autofit it?

DocumentBuilder builder = new DocumentBuilder();

builder.InsertHtml(File.ReadAllText(@"C:\Users\ingyadav\Desktop\audit report.html").ToString());

foreach (Aspose.Words.Tables.Table table in builder.Document.GetChildNodes(NodeType.Table, true))
{
    table.AutoFit(Aspose.Words.Tables.AutoFitBehavior.AutoFitToContents);
}

tried with this and the autofit property is not applied

can anyone please help me on this?

Hi Govardhan,

Thanks for your inquiry. We have tested the scenario using latest version of Aspose.Words for .NET 16.4.0 and have not found any issue with Table.AutoFit method. Please use Aspose.Words for .NET 16.4.0.

If you still face problem, please share your expected output document here for our reference. We will then provide you more information about your query along with code.