Original: http://www.cnblogs.com/LifelongLearning/archive/2011/06/22/2086802.html
Pdfptable and Pdfpcell objects, we can make a colorful table, you can create a cross-row, cross-column, different table lines, cell text rotation and other effects, as follows:
1. Text mode:
Pdfpcell cell = new Pdfpcell (New Paragraph ("some text"));
2. Combination mode:
Pdfpcell cell = new Pdfpcell (); Cell. AddElement (New Paragraph ("some text"));
These two differences:
In text mode, controls are used to control the alignment, spacing, and indentation of the content, using the properties of the object itself in the combined mode.
In the table, hide and set the color of the cell's border,
There is a property in Pdfpcell: Border border Property
This value is set using the following value:
Class Rectangle:element, IElement
2: {
3: int bottom_border = 2;
4: int BOX =;
5: int left_border = 4;
6: int no_border = 0;
7: int right_border = 8;
8: int top_border = 1;
And can be used in combination, such as: rectangle.top_border| Rectangle.left_border
Do not set the borderwidth=0 to hide the border, which will cause the table to be misaligned.
As shown in the following:
The first line of the default alignment left border is set to width 0, which clearly shows no alignment on the right.
Normal Condition:
To hide a border by setting Boder:
The code is as follows:
1:cell = Createcell (null);
2: cell. Border = Rectangle.right_border | Rectangle.top_border | Rectangle.bottom_border;
3: //cell. Useborderpadding = false;
4: //cell. Borderwidthleft = 0;
5: //cell. Bordercolortop = Basecolor.blue;
6: //cell. Borderwidthtop = 1;
7:
8: table. Addcell (cell);
Display effect:
For border color settings, if you want to set the color of the entire border, you can use Bodercolor, if you only set the color of the individual table lines, the use of Bordercolortop,bordercolorleft and other properties, and to set its width, Otherwise the color will not show up.
Code:
1:cell = Createcell (null);
2: cell. Border = Rectangle.right_border | Rectangle.top_border | Rectangle.bottom_border;
3: cell. BorderColor = basecolor.red;
4: cell. Bordercolortop = Basecolor.blue;
5: cell. Borderwidthtop = 0.5f;
6:
7: table. Addcell (cell);
Display effect:
Pdfpcell alignment, border, border color use (GO)