Home arrow Java & J2EE arrow Page 4 - Adding Columns With iTextSharp

Manually adding columns - Java

The iTextSharp library makes it very easy to create a PDF document with text. The text can be styled in various ways, aligned in various ways, indented and spaced in various ways, etc. When the PDF document must be printed out, the document's readability can be improved by breaking the text into columns. The iTextSharp library provides support for columns, and in this article, we're going to take a look at them.

  1. Adding Columns With iTextSharp
  2. An example
  3. Creating multiple columns
  4. Manually adding columns
By: Peyton McCullough
Rating: starstarstarstarstar / 7
June 24, 2008

print this article



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.

>>> More Java & J2EE Articles          >>> More By Peyton McCullough

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- More Java Bugs Lead to More Attacks
- Oracle's Java One Brings News, Surprises
- Oracle Patches Java Runtime Environment
- Apple Syncs Java Update with Oracle
- Spring 3.1 Java Development Framework Compat...
- Jelastic Java PaaS Availability and Pricing ...
- NetBeans 7.1 Released, Supports JavaFX 2
- SolarWinds Releases Newest Version of Java M...
- Free Monitoring Tool for Java Apps on Heroku
- Heroku Adds JCloud Platform Support, Java 7 ...
- Java SE 8 Speculation in Full Swing
- Java SE 7 Now Available
- New JVM Language and Java Reporting Tool
- Java 7 Release Update and New Eclipse Toolkit
- The Best Java Netbeans IDE Plugins

Developer Shed Affiliates


Dev Shed Tutorial Topics: