iTextSharp center align objects within the Document object

Since_2008 picture Since_2008 · Oct 1, 2010 · Viewed 69.9k times · Source

Is there a quick and simple way to center align objects within the Document object? Without performing any calculation logic, ie. Get width of page, get width of contents, divide by two, etc.

I have a PdfPTable object within a Paragraph object, within the Document object. I would like to center the Paragraph object.

Thanks!

Answer

JwL picture JwL · Jul 11, 2011

the equivalent replacement for iTextSharp :

paragraph.Alignment = Element.ALIGN_CENTER;

or try this way

paragraph.IndentationRight = 100;
paragraph.IndentationLeft = 100;