Adding Columns With iTextSharp - Manually adding columns
(Page 4 of 4 )
The AddRegularColumns method automatically sets up columns. However, there are some cases where more control is needed. In these cases, it's possible to manually add columns to a MultiColumnText object, and it's not very difficult to do, thankfully.
Simple columns can be added using the AddSimpleColumn method. This method takes two arguments: the distance of the left side of the column from the left side of the page, and the distance of the right side of the column from the left side of the page. Using this method, it would be possible to create two unequal columns on a page:
columns.AddSimpleColumn(72, 72 * 3);
columns.AddSimpleColumn(72 * 4, 72 * 7.5f);
In the example above, one column is created that is two inches wide, and another column is created that is three and a half inches wide. Once the columns are created, though, the basic behavior is the same. Text will automatically flow from one column to another on as many pages as needed.
Now you should be familiar with the basics of column creation in iTextSharp. Try creating a few examples of your own with columns.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |