# RadPdfProcessing Table Overview

Use the `Table` class to generate tabular content in PDF documents with RadPdfProcessing. You define rows, cells, styling, and layout settings, and then pass the table to [FixedContentEditor](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/fixedcontenteditor) or [RadFixedDocumentEditor](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/radfixeddocumenteditor) to measure, position, draw, and split it across pages.

This overview explains the table building blocks, the main layout properties, and the different ways to insert or draw a table so you can choose the right workflow for your document scenario.

![RadPdfProcessing table model diagram showing rows and cells](https://www.telerik.com/document-processing-libraries/documentation/assets/deadff0ca619667205742652606ab6a3/radpdfprocessing_editing_table_01.png)

Each table contains a series of [TableRow](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/table/tablerow) instances each of which contains a series of [TableCell](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/table/tablecell) instances. To define a simple table, generate the table cells and add some content to them.

Use this article when you need to:

* Create a PDF table from code.
* Apply shared styling to table cells.
* Control layout behavior such as width, spacing, and border collapse.
* Insert a table into a document by using `RadFixedDocumentEditor`.
* Draw a table with `FixedContentEditor` when you need extra placement control.
* Measure a table before you render it.

If you are new to the document editors, start with the editor choice in this article and then continue to the linked editor documentation for API details.

## Defining Table Content

Each `Table` contains a collection of [TableRow](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/table/tablerow) instances, and each row contains a collection of [TableCell](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/table/tablecell) instances. To create a table, add the required cells and then assign content to each cell.

1. Create a `Table` instance.
2. Add rows and cells.
3. Put content in each cell.
4. Apply layout and styling properties.
5. Insert or draw the table with the appropriate editor.

The following snippet creates a table with two rows and three columns and fills each cell with sample text.

**Create a Simple Table**

```C#
Table table = new Table();

TableRow firstRow = table.Rows.AddTableRow();
firstRow.Cells.AddTableCell().Blocks.AddBlock().InsertText("cell11");
firstRow.Cells.AddTableCell().Blocks.AddBlock().InsertText("cell12");
firstRow.Cells.AddTableCell().Blocks.AddBlock().InsertText("cell13");

TableRow secondRow = table.Rows.AddTableRow();
secondRow.Cells.AddTableCell().Blocks.AddBlock().InsertText("cell21");
secondRow.Cells.AddTableCell().Blocks.AddBlock().InsertText("cell22");
secondRow.Cells.AddTableCell().Blocks.AddBlock().InsertText("cell23");
```

The result is shown in the following image.

**Table**

![RadPdfProcessing simple table with two rows and three columns](https://www.telerik.com/document-processing-libraries/documentation/assets/14551e9d50410b4b39e2a8b62f849189/radpdfprocessing_editing_table_02.png)

## Using DefaultCellProperties

Use the table `DefaultCellProperties` property when the same styling should apply to every cell. This reduces repetitive cell-by-cell configuration and gives you a consistent base style for the whole table.

The most common default cell properties are:

| Property     | Description                                                                                                                                             |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Padding`    | Specifies the distances between the inner cell border contour and the cell content.                                                                     |
| `Borders`    | Of type `TableCellBorders`. Specifies the borders of a single cell. The available borders are left, right, top, bottom, diagonal up, and diagonal down. |
| `Background` | Specifies the background of the cell.                                                                                                                   |

The following snippet shows how to use the `DefaultCellProperties` of a table.

**Use DefaultCellProperties on a Table**

```C#
Table table = new Table();
Border redBorder = new Border(2, new RgbColor(255, 0, 0));
table.DefaultCellProperties.Borders = new TableCellBorders(redBorder);
table.DefaultCellProperties.Padding = new Thickness(20, 10, 20, 10);
table.DefaultCellProperties.Background = new RgbColor(0, 255, 0);

TableRow firstRow = table.Rows.AddTableRow();
firstRow.Cells.AddTableCell();
firstRow.Cells.AddTableCell();
firstRow.Cells.AddTableCell();

TableRow secondRow = table.Rows.AddTableRow();
secondRow.Cells.AddTableCell();
secondRow.Cells.AddTableCell();
secondRow.Cells.AddTableCell();
```

The result of the snippet is demonstrated in the following image.

**Result of DefaultCellProperties modification**
![RadPdfProcessing table with modified default cell properties](https://www.telerik.com/document-processing-libraries/documentation/assets/d50289a1355efb49c4f7e647b404b574/radpdfprocessing_editing_table_03.png)

## Modifying a Table

Several table properties affect measurement, spacing, and rendering behavior:

* **Margin**: Specifies the distances between the table borders outline and the rest of the document content.

* **Padding**: Set through the `TableCell` `Padding` property, it specifies the distances between cell borders inner contour and the cell content.

* **LayoutType**: Specifies the algorithm used to layout table contents. Two options are available in the `TableLayoutType` enumeration:

  * **AutoFit** (Default) – The table width fits the content unless the needed width is bigger than the available measuring width. Under `AutoFit`, columns expand to prevent text wrapping as long as the total table width fits within the available measuring space.
  * **FixedWidth** – The table width always fits the available measuring width.

* **HorizontalAlignment**: Specifies the alignment of the table inside the page.

* **BorderSpacing**: Specifies the distance between all the borders in the table. This distance is measured differently depending on the **BorderCollapse** option.

* **BorderCollapse**: Specifies the way the border spacing calculations are done. Two options are available:
  * **Collapse**: The distance between borders is measured from the middle lines of the borders.
  * **Separate**: The distance between borders is measured from the outer border contour.

* **Row and Line Spacing**: You can explicitly set individual row heights via the `Height` property of [TableRow](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/table/tablerow) using `HeightType` (`Auto`, `Exact`, `AtLeast`). Within cell blocks, vertical line spacing can be configured using `LineSpacing` and `LineSpacingType` on [Block](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/block).

The following snippets show how border calculations change when you switch the `BorderCollapse` option. The first snippet creates an empty table and applies default cell padding and a red table border with thickness `10`.

**Create a Table with a Red Border**

```C#
Table table = new Table();
table.DefaultCellProperties.Padding = new Thickness(10, 6, 10, 6);
Border redBorder = new Border(10, new RgbColor(255, 0, 0));
table.Borders = new TableBorders(redBorder);
```

The next snippet adds a single row with two cells to the table from the previous example. The first cell has a green border with thickness `5`, and the second cell has a blue border with thickness `3`.

**Add Green and Blue Cells**

```C#
TableRow tableRow = table.Rows.AddTableRow();

TableCell firstCell = tableRow.Cells.AddTableCell();
Border greenBorder = new Border(5, new RgbColor(0, 255, 0));
firstCell.Borders = new TableCellBorders(greenBorder, greenBorder, greenBorder, greenBorder);
firstCell.Blocks.AddBlock().InsertText("green bordered cell");

TableCell secondCell = tableRow.Cells.AddTableCell();
Border blueBorder = new Border(3, new RgbColor(0, 0, 255));
secondCell.Borders = new TableCellBorders(blueBorder, blueBorder, blueBorder, blueBorder);
secondCell.Blocks.AddBlock().InsertText("blue bordered cell");
```

The following image shows the table with the `BorderCollapse` property set to `Collapse`. All borders are drawn so that their middle lines coincide.

**Collapse Borders**

```C#
table.BorderCollapse = BorderCollapse.Collapse;
```

**Collapsed border**

![RadPdfProcessing table with collapsed borders](https://www.telerik.com/document-processing-libraries/documentation/assets/3993c523f48279aa3f4cc84480205085/radpdfprocessing_editing_table_04.png)

The following image shows the same table with `BorderCollapse` set to `Separate`, so the outer border contours coincide.

**Separate Borders**

```C#
table.BorderCollapse = BorderCollapse.Separate;
```

**Separated border**
![RadPdfProcessing table with separated borders](https://www.telerik.com/document-processing-libraries/documentation/assets/b40561faf1833e06d21094f6d1bf188f/radpdfprocessing_editing_table_05.png)

## Drawing Table with RadFixedDocumentEditor

Use `RadFixedDocumentEditor.InsertTable()` when you want the editor to place the table in the document flow and split it across pages when needed. This is the easier option for standard document-generation scenarios.

The following snippet creates a simple table with two cells.

**Create a Table**

```C#
Table table = new Table();

Border border = new Border();
table.Borders = new TableBorders(border);
table.DefaultCellProperties.Borders = new TableCellBorders(border, border, border, border);

table.BorderSpacing = 5;
table.BorderCollapse = BorderCollapse.Separate;

TableRow row = table.Rows.AddTableRow();
row.Cells.AddTableCell().Blocks.AddBlock().InsertText("First cell");
row.Cells.AddTableCell().Blocks.AddBlock().InsertText("Second cell");
```

The following snippet inserts the table in a `RadFixedDocumentEditor` and specifies the table layout type to `AutoFit`.

**Insert AutoFit table**

```C#
using (RadFixedDocumentEditor editor = new RadFixedDocumentEditor(document))
{
    table.LayoutType = TableLayoutType.AutoFit;
    editor.InsertTable(table);
}
```

The result is that the table width is exactly as needed for fitting the cell content, as visible in the following image.

**AutoFit table**

![RadPdfProcessing AutoFit table sized to its cell content](https://www.telerik.com/document-processing-libraries/documentation/assets/49b50361b99bc21efa91c1dc2d5f98ef/radpdfprocessing_editing_table_06.png)

Using `FixedWidth` produces different results because the editor fits the table to the available measuring width.

**Insert a `FixedWidth` Table**

```C#
using (RadFixedDocumentEditor editor = new RadFixedDocumentEditor(document))
{
    table.LayoutType = TableLayoutType.FixedWidth;
    editor.InsertTable(table);
}
```

**FixedWidth table**

![RadPdfProcessing FixedWidth table stretched to the available width](https://www.telerik.com/document-processing-libraries/documentation/assets/76d768ff04336d5fb4579de54c5ad3ed/radpdfprocessing_editing_table_07.png)

## Drawing Table with FixedContentEditor

Use `FixedContentEditor.DrawTable()` when you need lower-level drawing control, such as custom positioning, transforms, or rotation.

The following snippet draws a rotated table with `FixedContentEditor`.

**Draw a Rotated Table**

```C#
Table table = new Table();

TableRow firstRow = table.Rows.AddTableRow();
firstRow.Cells.AddTableCell().Blocks.AddBlock().InsertText("cell11");
firstRow.Cells.AddTableCell().Blocks.AddBlock().InsertText("cell12");
firstRow.Cells.AddTableCell().Blocks.AddBlock().InsertText("cell13");

TableRow secondRow = table.Rows.AddTableRow();
secondRow.Cells.AddTableCell().Blocks.AddBlock().InsertText("cell21");
secondRow.Cells.AddTableCell().Blocks.AddBlock().InsertText("cell22");
secondRow.Cells.AddTableCell().Blocks.AddBlock().InsertText("cell23");

RadFixedDocument document = new RadFixedDocument();
RadFixedPage page = document.Pages.AddPage();
FixedContentEditor editor = new FixedContentEditor(page, new SimplePosition());

editor.Position.Translate(10, 100);
editor.Position.Rotate(-45);
editor.DrawTable(table);
```

The following image shows a 45-degree rotated table similar to the AutoFit example.

**Rotated table**

![RadPdfProcessing rotated table drawn with FixedContentEditor](https://www.telerik.com/document-processing-libraries/documentation/assets/321bbaf6b8e27e2966a0b579de93e384/radpdfprocessing_editing_table_08.png)

## Measuring a Table

The `Table` class exposes `Measure` overloads that calculate and return the desired size of the table without drawing it. This is useful when you need to know the table dimensions before inserting it into a document, for example when you must decide whether to use a new page or position other content relative to the table.

Use one of these overloads:

* `Measure(CancellationToken)`: Measures the table against an infinite available size and returns the resulting `Size`.
* `Measure(Size, CancellationToken)`: Measures the table against a constrained available size when the table must fit within a known width or height.

The following snippet demonstrates both measurement approaches.

**Measure a Table**

```C#
Table table = new Table();
TableRow row = table.Rows.AddTableRow();
TableCell cell = row.Cells.AddTableCell();
cell.Blocks.AddBlock().InsertText("Sample content");

// Measure against an infinite available size.
Size measuredSize = table.Measure(CancellationToken.None);

// Obsolete since Q2 2026
// Size measuredSize = table.Measure();

// Measure against a constrained available size.
Size availableSize = new Size(500, 800);
Size constrainedSize = table.Measure(availableSize, CancellationToken.None);
```

## Supported Border Styles

Starting with **Q3 2024**, RadPdfProcessing supports the `Dotted`, `Dashed`, and `DashSmallGap` border styles in addition to `BorderStyle.Single`. Starting with the same release, `Dotted`, `Dashed`, `DashSmallGap`, and `Thick` border lines are also exported from [RadFlowDocument](https://www.telerik.com/document-processing-libraries/documentation/libraries/radwordsprocessing/model/radflowdocument) to [RadFixedDocument](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/radfixeddocument).

| BorderStyle    | Border design                                                                                                                                                                                                                               |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Single`       | ![RadPdfProcessing RadPdfProcessing Table Overview Preview of a single-line PDF table border](https://www.telerik.com/document-processing-libraries/documentation/assets/df330d93ea76b0058bca99abe1c317f0/pdf-single-border.png)            |
| `Dotted`       | ![RadPdfProcessing RadPdfProcessing Table Overview Preview of a dotted PDF table border](https://www.telerik.com/document-processing-libraries/documentation/assets/e8e54cef513f1831bf18655d229f0ab8/pdf-dotted-border.png)                 |
| `Dashed`       | ![RadPdfProcessing RadPdfProcessing Table Overview Preview of a dashed PDF table border](https://www.telerik.com/document-processing-libraries/documentation/assets/c1bed1761c018e56bd2b7cfa115a436f/pdf-dashed-border.png)                 |
| `DashSmallGap` | ![RadPdfProcessing RadPdfProcessing Table Overview Preview of a dash-small-gap PDF table border](https://www.telerik.com/document-processing-libraries/documentation/assets/6c1f133fdc0affd263a1bc7266332af0/pdf-dash-small-gap-border.png) |

## Next Steps

Continue with the article that matches your next task:

* [TableRow](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/table/tablerow) and [TableCell](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/table/tablecell)—Customize row-level or cell-level behavior
* [Generating a Table with RadFixedDocumentEditor](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/generate-table-with-radfixeddocumenteditor)—Follow a focused document-editor workflow
* [Creating Custom Layout Tables with RadPdfProcessing](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/customize-table-layout-radpdfprocessing)—Apply more advanced layout control
* [Avoiding Table Splits Across Pages Using FixedContentEditor in RadPdfProcessing](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/avoid-table-splits-across-pages-radpdfprocessing)—Handle page-breaking scenarios

## See Also

* [TableRow](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/table/tablerow)
* [TableCell](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/table/tablecell)
* [Block](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/block)
* [FixedContentEditor](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/fixedcontenteditor)
* [RadFixedDocumentEditor](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/radfixeddocumenteditor)
* [How to Generate a Table with Images with PdfProcessing](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/generate-table-with-images-pdf-processing)
* [Implementing Column Span in RadPdfProcessing Tables](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/table-column-span-radpdfprocessing)
* [How to Achieve Alternating Row Color for Tables in PdfProcessing](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/alternating-row-color-in-pdf-tables)
