Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have to align text to center on itextsharp pdf writer
I have no idea how to, I was able to center image using

C#
iTextSharp.text.Image companyLogo = iTextSharp.text.Image.GetInstance(logoURL);

C#
companyLogo.Alignment = iTextSharp.text.Image.ALIGN_CENTER;


my question is how can I align text to center?

C#
doc.Add(new iTextSharp.text.Paragraph(companyName + Environment.NewLine + companyAddress + Environment.NewLine + companyContact + Environment.NewLine));
Posted

1 solution

We have horizontal and vertical alignment properties

mTable.HorizontalAlignment = 0;
tCell.HorizontalAlignment = Element.ALIGN_CENTER;

I think You need to take company logo in a box or a table then align
for the page setting you can table box

for more help please see the following links


http://jwcooney.com/2014/01/04/itextsharp-pdfpcell-text-alignment-example/[^]

Creating PDF Tables using C# (.NET 2.0) and iTextSharp[^]


http://stackoverflow.com/questions/5512698/how-to-add-dynamic-text-to-pdf-toolbar-using-itextsharp[^]

http://aspsnippets.com/Articles/How-to-generate-and-download-PDF-Report-from-database-in-ASPNet-using-iTextSharp-C-and-VBNet.aspx[^]

http://www.mikesdotnetting.com/Article/89/iTextSharp-Page-Layout-with-Columns[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900