Sam Daniel
Sam Daniel

Reputation: 141

How to split content into two columns (need some space between the columns) using itextsharp

I am supposed to print a pdf using itextsharp. My requirement is to split the page into two columns (need some space between the columns). I dont have an idea how to do this. Can you help me on this. I am using the version 7(itext)

Upvotes: 0

Views: 1083

Answers (1)

Alexey Subach
Alexey Subach

Reputation: 12312

To have a multi-column rendering mode, you can use ColumnDocumentRenderer class:

Document document = new Document(pdfDocument);
Rectangle[] columns = new Rectangle[] {
     new Rectangle(30, 30, 200, 750), // coordinates of first column
     new Rectangle(300, 30, 200, 750) // coordinates of second column
}));
document.SetRenderer(new ColumnDocumentRenderer(document, columns)); 

Then just add elements to the document as usual:

document.Add(new Paragraph("Text string"));

Upvotes: 1

Related Questions