@@ -7,7 +7,7 @@ published: True
77position : 0
88---
99
10- # Table
10+ # Table Overview
1111
1212The ** Table** class helps you easily create tabular data content. All you need to do is define the table content and pass a Table instance to a [ FixedContentEditor] ({%slug radpdfprocessing-editing-fixedcontenteditor%}) or a [ RadFixedDocumentEditor] ({%slug radpdfprocessing-editing-radfixeddocumenteditor%}). From then on, these editors are responsible for positioning, measuring, drawing and splitting the table onto pages.
1313
@@ -36,21 +36,7 @@ __Example 1__ shows how to generate a simple table with two rows and three colum
3636
3737#### __ [ C#] Example 1: Create simple table__
3838
39- {{region cs-radpdfprocessing-editing-table_0}}
40- Table table = new Table();
41-
42- TableRow firstRow = table.Rows.AddTableRow();
43- firstRow.Cells.AddTableCell().Blocks.AddBlock().InsertText("cell11");
44- firstRow.Cells.AddTableCell().Blocks.AddBlock().InsertText("cell12");
45- firstRow.Cells.AddTableCell().Blocks.AddBlock().InsertText("cell13");
46-
47- TableRow secondRow = table.Rows.AddTableRow();
48- secondRow.Cells.AddTableCell().Blocks.AddBlock().InsertText("cell21");
49- secondRow.Cells.AddTableCell().Blocks.AddBlock().InsertText("cell22");
50- secondRow.Cells.AddTableCell().Blocks.AddBlock().InsertText("cell23");
51- {{endregion}}
52-
53-
39+ <snippet id =' libraries-pdf-editing-table-overview-create-simple-table ' />
5440
5541The result table is shown in __ Figure 1__ .
5642
@@ -73,25 +59,7 @@ __Еxample 2__ shows how to use the __DefaultCellProperties__ of a table
7359
7460#### __ [ C#] Example 2: Use DefaultCellProperties of Table__
7561
76- {{region cs-radpdfprocessing-editing-table_1}}
77- Table table = new Table();
78- Border redBorder = new Border(2, new RgbColor(255, 0, 0));
79- table.DefaultCellProperties.Borders = new TableCellBorders(redBorder);
80- table.DefaultCellProperties.Padding = new Thickness(20, 10, 20, 10);
81- table.DefaultCellProperties.Background = new RgbColor(0, 255, 0);
82-
83- TableRow firstRow = table.Rows.AddTableRow();
84- firstRow.Cells.AddTableCell();
85- firstRow.Cells.AddTableCell();
86- firstRow.Cells.AddTableCell();
87-
88- TableRow secondRow = table.Rows.AddTableRow();
89- secondRow.Cells.AddTableCell();
90- secondRow.Cells.AddTableCell();
91- secondRow.Cells.AddTableCell();
92- {{endregion}}
93-
94-
62+ <snippet id =' libraries-pdf-editing-table-overview-use-default-cell-properties-of-table ' />
9563
9664The result of the snippet in __ Example 2__ is demonstrated on __ Figure 2__ .
9765
@@ -127,46 +95,21 @@ __Example 3__ demonstrates how border calculations occur with different __Border
12795
12896#### __ [ C#] Example 3: Create table with red border__
12997
130- {{region cs-radpdfprocessing-editing-table_2}}
131- Table table = new Table();
132- table.DefaultCellProperties.Padding = new Thickness(10, 6, 10, 6);
133- Border redBorder = new Border(10, new RgbColor(255, 0, 0));
134- table.Borders = new TableBorders(redBorder);
135- {{endregion}}
136-
137-
98+ <snippet id =' libraries-pdf-editing-table-overview-create-table-with-red-border ' />
13899
139100__ Example 4__ adds a single row with two cells to the table from __ Example 3__ . The first cell has a green border with thickness 5 while the second cell has a blue border with thickness 3.
140101
141102
142103#### __ [ C#] Example 4: Add green and blue cells__
143104
144- {{region cs-radpdfprocessing-editing-table_3}}
145- TableRow tableRow = table.Rows.AddTableRow();
146-
147- TableCell firstCell = tableRow.Cells.AddTableCell();
148- Border greenBorder = new Border(5, new RgbColor(0, 255, 0));
149- firstCell.Borders = new TableCellBorders(greenBorder, greenBorder, greenBorder, greenBorder);
150- firstCell.Blocks.AddBlock().InsertText("green bordered cell");
151-
152- TableCell secondCell = tableRow.Cells.AddTableCell();
153- Border blueBorder = new Border(3, new RgbColor(0, 0, 255));
154- secondCell.Borders = new TableCellBorders(blueBorder, blueBorder, blueBorder, blueBorder);
155- secondCell.Blocks.AddBlock().InsertText("blue bordered cell");
156- {{endregion}}
157-
158-
105+ <snippet id =' libraries-pdf-editing-table-overview-add-green-and-blue-cells-to-table ' />
159106
160107__ Figure 3__ shows the table from Example 3 and 4 with BorderCollapse property set to Collapse - all borders are drawn so that their middle lines coincide.
161108
162109
163110#### __ [ C#] Example 5: Collapse border__
164111
165- {{region cs-radpdfprocessing-editing-table_4}}
166- table.BorderCollapse = BorderCollapse.Collapse;
167- {{endregion}}
168-
169-
112+ <snippet id =' libraries-pdf-editing-table-overview-collapse-table-border ' />
170113
171114#### Figure 3: Collapsed border
172115![ Rad Pdf Processing Editing Table 04] ( images/RadPdfProcessing_Editing_Table_04.png )
@@ -176,11 +119,7 @@ __Figure 4__ shows the same table with BorderCollapse property set to Separate -
176119
177120#### __ [ C#] Example 6: Separate border__
178121
179- {{region cs-radpdfprocessing-editing-table_5}}
180- table.BorderCollapse = BorderCollapse.Separate;
181- {{endregion}}
182-
183-
122+ <snippet id =' libraries-pdf-editing-table-overview-separate-table-border ' />
184123
185124#### Figure 4: Separated border
186125![ Rad Pdf Processing Editing Table 05] ( images/RadPdfProcessing_Editing_Table_05.png )
@@ -195,37 +134,14 @@ __Example 7__ generates a simple table with two cells.
195134
196135#### __ [ C#] Example 7: Create table__
197136
198- {{region cs-radpdfprocessing-editing-table_6}}
199- Table table = new Table();
200-
201- Border border = new Border();
202- table.Borders = new TableBorders(border);
203- table.DefaultCellProperties.Borders = new TableCellBorders(border, border, border, border);
204-
205- table.BorderSpacing = 5;
206- table.BorderCollapse = BorderCollapse.Separate;
207-
208- TableRow row = table.Rows.AddTableRow();
209- row.Cells.AddTableCell().Blocks.AddBlock().InsertText("First cell");
210- row.Cells.AddTableCell().Blocks.AddBlock().InsertText("Second cell");
211- {{endregion}}
212-
213-
137+ <snippet id =' libraries-pdf-editing-table-overview-create-table ' />
214138
215139__ Example 8__ inserts the table from __ Example 7__ in a RadFixedDocumentEditor and specifies the table layout type to AutoFit.
216140
217141
218142#### __ [ C#] Example 8: Insert AutoFit table__
219143
220- {{region cs-radpdfprocessing-editing-table_7}}
221- using (RadFixedDocumentEditor editor = new RadFixedDocumentEditor(document))
222- {
223- table.LayoutType = TableLayoutType.AutoFit;
224- editor.InsertTable(table);
225- }
226- {{endregion}}
227-
228-
144+ <snippet id =' libraries-pdf-editing-table-overview-insert-autofit-table ' />
229145
230146The result is that the table width is exactly as needed for fitting the cells content as visible in __ Figure 5__ .
231147
@@ -238,12 +154,7 @@ Specifying FixedWidth layout option produces different results.
238154
239155#### __ [ C#] Example 9: Insert FixedWidth table__
240156
241- {{region cs-radpdfprocessing-editing-table_8}}
242- table.LayoutType = TableLayoutType.FixedWidth;
243- editor.InsertTable(table);
244- {{endregion}}
245-
246-
157+ <snippet id =' libraries-pdf-editing-table-overview-insert-fixed-width-table ' />
247158
248159#### Figure 6: FixedWidth table
249160![ Rad Pdf Processing Editing Table 07] ( images/RadPdfProcessing_Editing_Table_07.png )
@@ -258,19 +169,7 @@ __Example 10__ shows how to draw a rotated table with the help of FixedContentEd
258169
259170#### __ [ C#] Example 10: Draw rotated table__
260171
261- {{region cs-radpdfprocessing-editing-table_9}}
262- Table table = GenerateSampleTable();
263-
264- RadFixedDocument document = new RadFixedDocument();
265- RadFixedPage page = document.Pages.AddPage();
266- FixedContentEditor editor = new FixedContentEditor(page, new SimplePosition());
267-
268- editor.Position.Translate(10, 100);
269- editor.Position.Rotate(-45);
270- editor.DrawTable(table);
271- {{endregion}}
272-
273-
172+ <snippet id =' libraries-pdf-editing-table-overview-draw-rotated-table ' />
274173
275174As a result, on __ Figure 7__ you can see a 45-degree rotated table similar to the one on Figure 5.
276175
0 commit comments