Summary of itextsharp page settings

Source: Internet
Author: User

Http://blog.dic123.com/article.asp? Id = 469

Summary of page settings
In itextsharp, the page size, color, and margin are controlled by the document object constructor. The Document Object in itextsharp has three constructors:
1. Public document ();
2. Public document (rectangle pagesize );
3. Public document (rectangle pagesize, int marginleft, int marginright, int margintop, int marginbottom );
The first constructor does not have any parameters. In actual internal implementation, the first constructor calls the second constructor and sets the parameter of the second constructor to A4 size by default, the second constructor will be explained later.
The second constructor calls the third constructor. The four margin parameters are set to 36 pixels by default. The second constructor parameter can be set in two ways, one is custom page width and height, and the other is set to the values of several page sizes specified in the pagesize class. When using custom settings, first define a rectangle object and specify the width and height of the page in the rectangle object constructor, for example, rectangle pagesize = new rectangle (144,720 ); this is to define a page with a width of 144 pixels and a height of 720 pixels, and then specify this object in the parameters of the document object constructor. When you set with the pagesize class, you can specify the paper size, A0-A10, as listed below,
Legal, letter, halfletter, _ 11x17, ledger, note, B0-B5, ARCH_A-ARCH_E, FLSA and flse. For example, document = new document (pagesize. a4). In addition, if you want to rotate the configured page, the setting method is as follows: Document document = new document (pagesize. a4.rotate ());
The third constructor has four more parameters than the second constructor. From the literal meaning, we can understand that these four parameters are used to specify the margins of the upper and lower sides of the left and right sides.
Next we will introduce how to specify the page color. Only the second and third constructors have this function. The rectangle object has a backgroundcolor attribute to specify the background color. The setting method is as follows: pagesize. backgroundcolor = new color (0xff, 0xff, 0xde); or
Pagesize. a4.backgroundcolor = new color (0xff, 0xff, 0xde ).
Note: The rectangle object, color object, and. the two objects in the. NET system have the same names. Therefore, developers are reminded that if these two objects are involved in itextsharp development, they must use a complete namespace to specify the object, as shown below: 1. itextsharp. text. rectangle pagesize = newitextsharp. text. rectangle (144,270 );

2. pagesize. backgroundcolor = new itextsharp. Text. color (0xff, 0xff, 0xde );

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.