Exception is being thrown for a particular table for attached document while performing AutoFitToWindow .
@hrnallap Could you please attach the problematic input document and provide a simple code that will allow us to reproduce the problem? We will check the issue and provide you more information.
Below is the sample code we are using which is failing During Auto fit. Also attached the problematic document.
//auto the tables to avoid table truncation
foreach (Aspose.Words.Tables.Table t in doc.GetChildNodes(NodeType.Table, true))
{
// Set the preferred width of the table to 16 cm
// t.PreferredWidth = PreferredWidth.FromPoints(16 * 28.35f); // 1 cm = 28.35 points
PageSetup ps = ((Section)t.GetAncestor(NodeType.Section)).PageSetup;
// ps.PaperSize =
ps.PageWidth = ConvertUtil.InchToPoint(15);
ps.PageHeight = ConvertUtil.InchToPoint(11);
ps.Margins = Margins.Narrow;
try
{
t.AutoFit(AutoFitBehavior.AutoFitToWindow);
}
//todo remove
catch (Exception ex)
{
Logger.Error("Exception occured while performing AutoFit for below node -" + ex.Message + " : " + ex.StackTrace);
Logger.Debug(t.Range.Text);
Console.WriteLine("Exception occured while performing AutoFit :" + ex.Message);
throw ex;
}
}
I couldnt upload .doc so converted to pdf. Please convert it to .doc when you are testing.
Document Truncation Exception.pdf (116.8 KB)
@hrnallap
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): WORDSNET-28359
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
Could you pls let me know what is the ETA for this ? We have purchased license . Does this count for Paid Support Services?
@hrnallap The issue is not yet scheduled for development. So we cannot provide you estimate right now. We will keep you updated and let you know once it is resolved.
We have already completed analyzing the issue. Table has zero preferred width specified that is not expected by autofit code. So as a temporary workaround you can set preferred width to not zero value:
Document doc = new Document(@"C:\Temp\in.doc");
Table t = doc.FirstSection.Body.Tables[0];
// Workaround
if (t.PreferredWidth.Value == 0)
t.PreferredWidth = PreferredWidth.FromPercent(100);
t.AutoFit(AutoFitBehavior.AutoFitToWindow);
doc.Save(@"C:\Temp\out.docx");
No, the license and Paid Support Services are different products and Paid Support Services should be purchased separately. You can contact our sales team in Aspose.Purchase forum for more details.
Thank for the workaround. Is it recommended to set the PreferredWidth ? Does it resize or shrink the images within the tables ?
The issues you have found earlier (filed as WORDSNET-28359) have been fixed in this Aspose.Words for .NET 25.8 update also available on NuGet.
