Free Support Forum -

Dynamically resizable table rows with text fields

Good evening,

I am making a table report that saves to a PDF. The table has text fields in it. The rows do not have a fixed row height set. What I would like to happen is for the table row to grow if the user enters more text than the text area allows.

Thanks in advance,


This message was posted using Aspose.Live 2 Forum

Hello Bill,

Thanks for considering Aspose.

The width of the table row and cell is automatically adjusted based over its contents. Please take a look over the following code snippet and the resultant PDF that I've generated using v4.1.0.0.


Pdf pdf = new Pdf();
Aspose.Pdf.Section sec = pdf.Sections.Add();

//Instantiate a table object
Table tab1 = new Table();
//Add the table in paragraphs collection of the desired section\
//Set with column widths of the table
tab1.ColumnWidths = "100 100 100";
//Set default cell border using BorderInfo object
tab1.DefaultCellBorder = new BorderInfo((int)BorderSide.All, 0.1F);
//Set table border using another customized BorderInfo object
tab1.Border = new BorderInfo((int)BorderSide.All, 1F);

//Create MarginInfo object and set its left, bottom, right and top margins
MarginInfo margin = new 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
Row row1 = tab1.Rows.Add();
row1.Cells.Add("col1 has a very long string");

Row row2 = tab1.Rows.Add();
row2.Cells.Add("item2 over 2nd row has a very long text string tooo....");


In case I've not properly understood your requirement or you've any further query, feel free to share.

No, I have a FormField component of type Text in the cell. After I generate the PDF, I would like to type text in it. If I type a lot of text, then some of it is hidden because too much text was typed.

Hello Bill,

Thanks for sharing the details.

As far as I can understand, you are creating a PDF form, and in one of the text field when user types more text as compare to the width of the field, you want the rows to expand automatically to fit the contents. If so is the case, then I'm afraid it’s not possible with Aspose.Pdf. Whereas, you can set the text field as Multiline, so that if the text length exceeds the width of the field, a slide bar is displayed. You can use the following line to set the field as Multiline.


textfield.TextIsMultiLine = true;<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

In case, it does not satisfy your requirement or you've any further query, please feel free to contact.