iTextSharp table.SpacingBefore not working

∥☆過路亽.° 提交于 2019-12-10 13:45:57

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/15275165/itextsharp-table-spacingbefore-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!