iTextSharp table.SpacingBefore not working
Asked Answered
L

1

5

I have a table which I'm trying to space down about 20/30 floating points (f) from the top margin of a pdf document. The reason I want to space down a bit is because I have a rectangle border running around the margin of my pdf document.

PdfPTable table = new PdfPTable(1);
table.SpacingBefore = 20f;
table.SpacingAfter = 20f;
table.TotalWidth = 700f;
table.LockedWidth = true;

table.SpacingAfter works perfectly well but table.SpacingBefore will not, my table just sits at the top margin and will not space/pad down at all.

Lonnie answered 7/3, 2013 at 15:32 Comment(0)
S
12

Check out the answer here that says that if a table is inserted as the first item in a document then SpacingBefore is ignored and that is by design. According to the post the solution is to add an empty paragraph with zero leading.

Salve answered 7/3, 2013 at 19:22 Comment(2)
adding some sample code to the answer would be helpful, the link could go down then there would be no sample.Depew
the paragraph should be with new Paragraph(" ") witch is different than new Paragraph(string.Empty)Patrolman

© 2022 - 2024 — McMap. All rights reserved.