Adding Text Below the Table in the Document
This topic shows how to use the C1.C1PrintDocument.RenderTable object to render the text into the block flow. It also demonstrates how to use the Padding property to advance the block position so that the next render object (in this case, text) is rendered there. In this topic we will use the Padding property to put the text 1 cm below the table in your document. This topic assumes you already have a table created.
1. Use the C1.C1PrintDocument.RenderTable object to create the text to be displayed:
Dim caption As C1.C1Preview.RenderText = New C1.C1Preview.RenderText(Me.C1PrintDocument1)
caption.Text = "In the table above, there are three rows and three columns."
• C#
C1.C1Preview.RenderText caption = new C1.C1Preview.RenderText(this.c1PrintDocument1);
caption.Text = "In the table above, there are three rows and three columns.";
2. Use the Padding property to position the text 1 cm below the table:
caption.Style.Padding.Top = New C1.C1Preview.Unit(1, C1.C1Preview.UnitTypeEnum.Cm)
• C#
caption.Style.Padding.Top = new C1.C1Preview.Unit(1, C1.C1Preview.UnitTypeEnum.Cm);
3. Add the text below the table using the Add method. Insert the Add method for the text below the Add method for the table, as shown in the following code:
Me.C1PrintDocument1.Body.Children.Add(table)
Me.C1PrintDocument1.Body.Children.Add(caption)
• C#
this.c1PrintDocument1.Body.Children.Add(table);
this.c1PrintDocument1.Body.Children.Add(caption);
Note: Placing the Add method for the text below the Add method for the table inserts the text below the table. If it is placed above the Add method for the table, the text will appear above the table.
Run the program and observe the following:
Your document should appear similar to the document below:
|