Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# iTextSharp table.Spacing不工作前_C#_Pdf_Itextsharp_Itext - Fatal编程技术网

C# iTextSharp table.Spacing不工作前

C# iTextSharp table.Spacing不工作前,c#,pdf,itextsharp,itext,C#,Pdf,Itextsharp,Itext,我有一个表格,我正试图从pdf文档的上边距中减去大约20/30个浮点(f)。我之所以要缩小一点空间,是因为我的pdf文档的边距周围有一个矩形边框 PdfPTable table = new PdfPTable(1); table.SpacingBefore = 20f; table.SpacingAfter = 20f; table.TotalWidth = 700f; table.LockedWidth = true; table.SpacingAfter工作得很好,但是table.Spac

我有一个表格,我正试图从pdf文档的上边距中减去大约20/30个浮点(f)。我之所以要缩小一点空间,是因为我的pdf文档的边距周围有一个矩形边框

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

table.SpacingAfter
工作得很好,但是
table.SpacingBefore
不会,我的桌子只是放在上边距,根本不会空格/填充。

检查一下,如果表格作为文档中的第一项插入,那么
SpacingBefore
将被忽略,这是出于设计。根据帖子,解决方案是添加一个空段落,前导为零。

在答案中添加一些示例代码会很有帮助,链接可能会关闭,这样就不会有示例。该段落应该包含
新段落(“”)
,这与
新段落(string.empty)