Skip to content

Commit f1ffecf

Browse files
committed
Extracted code snippets
1 parent 41d0d12 commit f1ffecf

File tree

3 files changed

+17
-146
lines changed

3 files changed

+17
-146
lines changed

libraries/radpdfprocessing/editing/table/overview.md

Lines changed: 11 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ published: True
77
position: 0
88
---
99

10-
# Table
10+
# Table Overview
1111

1212
The **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

5541
The 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

9664
The 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

230146
The 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

275174
As a result, on __Figure 7__ you can see a 45-degree rotated table similar to the one on Figure 5.
276175

libraries/radpdfprocessing/editing/table/tablecell.md

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,7 @@ The code snippet in __Example 1__ shows how to create a table with a single row
2929

3030
#### __[C#] Example 1: Create TableCell__
3131

32-
{{region cs-radpdfprocessing-editing-tablecell_0}}
33-
Table table = new Table();
34-
TableRow firstRow = table.Rows.AddTableRow();
35-
TableCell firstCell = firstRow.Cells.AddTableCell();
36-
{{endregion}}
37-
38-
32+
<snippet id='libraries-pdf-editing-table-tablecell-create-tablecell'/>
3933

4034
## Adding Cell Content
4135

@@ -47,12 +41,7 @@ __Example 2__ shows how to create a cell with a single [Block]({%slug radpdfproc
4741

4842
#### __[C#] Example 2: Add content to TableCell__
4943

50-
{{region cs-radpdfprocessing-editing-tablecell_1}}
51-
Block block = firstCell.Blocks.AddBlock();
52-
block.InsertText("Text in the cell.");
53-
{{endregion}}
54-
55-
44+
<snippet id='libraries-pdf-editing-table-tablecell-add-content-to-tablecell'/>
5645

5746
## Modifying a TableCell
5847

@@ -82,17 +71,9 @@ __Example 3__ demonstrates how to set locally the cell properties to a specific
8271

8372
#### __[C#] Example 1: Change TableCell appearance__
8473

85-
{{region cs-radpdfprocessing-editing-tablecell_2}}
86-
firstCell.RowSpan = 2;
87-
firstCell.ColumnSpan = 2;
88-
firstCell.Borders = new TableCellBorders(new Border(1, new RgbColor(150, 0, 0)));
89-
firstCell.Background = new RgbColor(255, 100, 100);
90-
{{endregion}}
91-
92-
74+
<snippet id='libraries-pdf-editing-table-tablecell-change-tablecell-appearance'/>
9375

9476
The result from __Example 3__ is illustrated on __Figure 1__.
95-
9677

9778
#### Figure 1: TableCell
9879
![Rad Pdf Processing Editing Table Cell 01](images/RadPdfProcessing_Editing_TableCell_01.png)

libraries/radpdfprocessing/editing/table/tablerow.md

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,7 @@ The code snippet in __Example 1__ shows how to create a table and add a single r
2828

2929
#### __[C#] Example 1: Create TableRow__
3030

31-
{{region cs-radpdfprocessing-editing-tablerow_0}}
32-
Table table = new Table();
33-
TableRow tableRow = table.Rows.AddTableRow();
34-
{{endregion}}
35-
36-
31+
<snippet id='libraries-pdf-editing-table-tablerow-create-tablerow'/>
3732

3833
## Using TableCellCollection
3934

@@ -45,11 +40,7 @@ __Example 2__ shows how to add two cells in a row and get the cells count.
4540

4641
#### __[C#] Example 2: Access cells in a TableRow__
4742

48-
{{region cs-radpdfprocessing-editing-tablerow_1}}
49-
TableCell firstCell = tableRow.Cells.AddTableCell();
50-
TableCell secondCell = tableRow.Cells.AddTableCell();
51-
int cellsInRowCount = tableRow.Cells.Count;
52-
{{endregion}}
43+
<snippet id='libraries-pdf-editing-table-tablerow-add-cells'/>
5344

5445
## Setting TableRow Height
5546

@@ -65,7 +56,7 @@ __Example 3__ creates a table with three single-cell rows, each with a different
6556

6657
#### __[C#] Example 3: Set TableRow height__
6758

68-
<snippet id='libraries-pdf-editing-tablerow-set-tablerow-height'/>
59+
<snippet id='libraries-pdf-editing-table-tablerow-set-tablerow-height'/>
6960

7061
![Rad Pdf Processing Editing TableRow Height](images/RadPdfProcessing_Editing_TableRow_Height.png)
7162

0 commit comments

Comments
 (0)