iTextSharp table.SpacingBefore not not working

use*_*185 5 c# pdf itext itextsharp

我有一张桌子,我试图从pdf文件的上边缘向下约20/30个浮点(f).我想稍微向下空间的原因是因为我的pdf文档边缘有一个矩形边框.

PdfPTable table = new PdfPTable(1);
table.SpacingBefore = 20f;
table.SpacingAfter = 20f;
table.TotalWidth = 700f;
table.LockedWidth = true;
Run Code Online (Sandbox Code Playgroud)

table.SpacingAfter工作得非常好,但table.SpacingBefore不会,我的桌子只是坐在上边缘,根本不会空间/垫.

Chr*_*aas 11

看看这里答案说,如果一个表被插入作为文档中的第一个项目,那么将SpacingBefore被忽略,这是设计的.根据帖子,解决方案是添加一个零段前导的空段落.