Document.UpdateTableLayout changes the layout of table in output PDF using .NET

hello,

Some tables are goes out of the page through InsertHTML() method. I try to set <TABLE style="WIDTH: 100%, from link
but it does not work. Could you please suggest me how to adjust table width?
Attachment are HTML and result.docx.table width.zip (14.4 KB)
Thanks.

@JasonMei

You can use Table.AutoFit as shown below to get the desired output. Hope this helps you.

foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
{
    table.AutoFit(AutoFitBehavior.AutoFitToWindow);
}
doc.Save(MyDir + "output.docx");

Thanks for your help.
I have an another issue for word to pdf. I use this docx with AutoFitWindow to convert to pdf, the table in pdf(page 14,15) is ok ,but student info table(pdf page 1) will miss content. image.png (63.9 KB)

Then I use method doc.UpdateTableLayout(), but the table in pdf goes out of page(page14,15 at [page14 table goes out with UpdateTableLayout method.pdf] my attach).image.png (151.4 KB).
I have to call doc.UpdateTableLayout() method for other tables in my document.

Could you please suggest me how to do?
Attachments are word and result file. auto fit window.zip (3.5 MB)

Thanks.

@JasonMei

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

We apologize for your inconvenience.

Thanks for your help.
Is there workaround for this scenario?

@JasonMei

Unfortunately, there is no workaround available for this issue.

You do not normally need to call UpdateTableLayout method. You can call this method before exporting to PDF (or any other fixed-page format), only in rare cases where you confirmed that tables appear incorrectly laid out in the output document.

The issues you have found earlier (filed as WORDSNET-20838) have been fixed in this Aspose.Words for .NET 23.7 update also available on NuGet.