Introduction
During work I faced one requirement where I had to bind multiple chunks into a single phrase and show these chunks at both the ends; i.e., left and right end, of the same line. So here I will explain how I completed that point.
Here I take one Phrase, ph1, and I have two strings, Project name, which contain the name of the Project and Date. I want to display the Project name at the left side and Date at the right side in a single line.
- Document doc = new document()
- Paragraph para = new Paragraph();
- doc.open()
- Chunk glue = new Chunk(new VerticalPositionMark());
- Phrase ph1 = new Phrase();
- ph1.Add(new Chunk(Environment.NewLine));
- string projectname = "Project Name: " + dr["ProjectName"].ToString();
- string date = dr["StartDate"].ToString() + "-" + dr["EndDate"].ToString();
- Paragraph main = new Paragraph();
- ph1.Add(new Chunk(projectname)); // Here I add projectname as a chunk into Phrase.
- ph1.Add(glue); // Here I add special chunk to the same phrase.
- ph1.Add(new Chunk('('+date +')')); // Here I add date as a chunk into same phrase.
- main.Add(ph1);
- para.Add(main);
- doc.Add(para);
- doc.close();

Summary
In this blog we saw how we can add multiple chunks into a single phrase, and how we can add two chunks at different locations using a single phrase.
Himanshu SharmaPosted Dec 8, 2018, 1:17 PM
I want to create four columns with one heading in a landscape view and their respective values in front of them
Pavan muppallaPosted Sep 16, 2018, 12:53 AM
ITextSharp.text.pdf.draw.VerticalPositionMark()
Pavan muppallaPosted Sep 16, 2018, 12:52 AM
ITextSharp.text.pdf.draw.VerticalPositionMark()
Bhavesh JadavPosted Nov 16, 2017, 8:00 AM
I have error for VerticalPositionMark() can not be found, please help
Atul RawatPosted Jun 9, 2016, 2:35 AM
nice blog