Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to give margin left to table in itextsharp

I am using these code ...my tables are sticked to left side of document as i havent given any paddings in document...

Document document = new Document(PageSize.A4, 0, 0, 0, 0);

But now i want to give margin left and margin right to my tables ...i used

outerTable.SpacingBefore = 20f;

it did n't work then i tried to give padding left to my cell it didnt work too..

outerCell.PaddingLeft = 20f;

Now my tables are sticked to left sides..how would i move them? Help if you have done trying moving tables in itextsharp...

pls check attached screen for reference

enter image description here

like image 419
ankit sharma Avatar asked Oct 14 '15 17:10

ankit sharma


1 Answers

The easiest way to get a table with a "left margin" is probably to wrap the table in a paragraph and set a left indentation on that paragraph

Paragraph p = new Paragraph();
p.IndentationLeft = 100;
outerTable.HorizontalAlignment = Element.ALIGN_LEFT;
p.Add(outerTable);
document.Add(p);
like image 195
rhens Avatar answered Oct 10 '22 09:10

rhens