Wrong cell width in tables

Hi,

I generate a word document with some tables. I want to autofit the tables based on the content.

table.AutoFit(AutoFitBehavior.AutoFitToContents);

When I save this document as .docx this is working correctly.
When I save this document as .pdf the contents of these tables get wrapped.
Before I save the document I perform a UpdateTableLayout

doc.UpdateTableLayout();

I have attached the two created files as an example.

I want the pdf-file to be the same as the docx-file.
How can I achieve this?

Paul

Hi Paul,

Thanks for your inquiry. In your case, please use the following code to disable text wrapping in a Cell:

Document doc = new Document(@"C:\Temp\Report_20121012_094329.docx");
foreach(Table tbl in doc.GetChildNodes(NodeType.Table, true))
{
    tbl.AutoFit(AutoFitBehavior.AutoFitToContents);
    foreach(Cell c in tbl.GetChildNodes(NodeType.Cell, true))
    c.CellFormat.WrapText = false;
}
doc.UpdateTableLayout();
doc.Save(@"C:\Temp\out.pdf");

I hope, this helps.

Best Regards,