Pdfpcell alignment, border, border color usage

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.