We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How FitToContent and IsWordWrapped in table and cell works

Hello,

Please refer attached PDF, I have set column adjustment property to auto fit to content.

And i have set IsWordWrapped property to false.



but it is wrapping the text.

I want column to be resized according to the largest fragment without word wrapping.

Like in attached document I want ABCD EFGH in single line only.



how this can be achieved?

Hi Sameer,


Thanks for using our API’s.

I have tested the scenario and have managed to produce the correct output. Please check below sample code. I have also attached the output PDF document for your reference.

C#
// Instntiate the Pdf object by calling its empty constructor
Document doc = new Document();
// Create the section in the Pdf object
Page sec1 = doc.Pages.Add();
// Instantiate a table object
Aspose.Pdf.Table tab1 = new Aspose.Pdf.Table();
// Add the table in paragraphs collection of the desired section
sec1.Paragraphs.Add(tab1);
// Set with column widths of the table
//tab1.ColumnWidths = “50 50 50”;
tab1.ColumnAdjustment = ColumnAdjustment.AutoFitToWindow;
// Set default cell border using BorderInfo object
tab1.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, 0.1F);
// Set table border using another customized BorderInfo object
tab1.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, 1F);
// Create MarginInfo object and set its left, bottom, right and top margins
Aspose.Pdf.MarginInfo margin = new Aspose.Pdf.MarginInfo();
margin.Top = 5f;
margin.Left = 5f;
margin.Right = 5f;
margin.Bottom = 5f;
// Set the default cell padding to the MarginInfo object
tab1.DefaultCellPadding = margin;
// Create rows in the table and then cells in the rows
Aspose.Pdf.Row row1 = tab1.Rows.Add();
row1.Cells.Add(“Root Node”);
Aspose.Pdf.Row row2 = tab1.Rows.Add();
row2.Cells.Add(“ABCDEFGH”);
row2.Cells.Add(“TC1”);
row2.Cells.Add(“TC2”);

Aspose.Pdf.Row row3 = tab1.Rows.Add();
row3.Cells.Add(“WD”);
row3.Cells.Add(“WD”);
row3.Cells.Add(“WD”);

Aspose.Pdf.Row row4 = tab1.Rows.Add();
row4.Cells.Add(“AW”);
row4.Cells.Add(“AW1”);
row4.Cells.Add(“AW”);
row4.Cells.Add(“AW1”);
row4.Cells.Add(“AW”);
row4.Cells.Add(“AW1”);

dataDir = dataDir + “AutoFitToWindow_out1.pdf”;
// Save updated document containing table object
doc.Save(dataDir);

However, if you still face any issue please share your sample code for further assistance.

Best Regards,