I couldn't get NextColumn()
to work wih a MultiColumnText
object and I couldn't find any samples (in .NET) that do.
A MultiColumnText
makes creating columns in a document relatively easy but in exchange you give up a lot control over layout. You can use the ColumnText
object which gives you a great deal of control over column layout but requires more code.
Here's a simple but complete example of what you're trying to do using ColumnText
:
private void TestColumnText() {
using (FileStream fs = new FileStream("ColumnTest.pdf", FileMode.Create)) {
Document doc = new Document();
PdfWriter writer = PdfWriter.GetInstance(doc, fs);
doc.Open();
PdfContentByte cb = writer.DirectContent;
ColumnText ct = new ColumnText(cb);
float columnWidth = 200f;
float[] left1 = { doc.Left + 90f, doc.Top - 80f, doc.Left + 90f, doc.Top - 170f, doc.Left, doc.Top - 170f, doc.Left, doc.Bottom };
float[] right1 = { doc.Left + columnWidth, doc.Top - 80f, doc.Left + columnWidth, doc.Bottom };
float[] left2 = { doc.Right - columnWidth, doc.Top - 80f, doc.Right - columnWidth, doc.Bottom };
float[] right2 = { doc.Right, doc.Top - 80f, doc.Right, doc.Bottom };
// Add content for left column.
ct.SetColumns(left1, right1);
ct.AddText(new Paragraph("Para 1"));
ct.Go();
// Add content for right column.
ct.SetColumns(left2, right2);
ct.AddText(new Paragraph("Para 2"));
ct.Go();
doc.Close();
}
}
Warning: As I mentioned, this is a simple example and won't even serve as a starting point for you in what you're trying to do. The samples on the sites below (especially the first one) will help you:
http://www.mikesdotnetting.com/Article/89/iTextSharp-Page-Layout-with-Columns
http://www.devshed.com/c/a/Java/Adding-Columns-With-iTextSharp