我正在使用iTextSharp生成一些PDF文件.我有两个有内容的表,我想在两个表之间放一些空格,比如相当于1行文本(使用与空格周围的表相同的字体).
下面是我用来添加两个表的代码.我无法弄清楚的是如何在两个表之间放置一个垂直空间.
Table upperTable = new Table(1);
upperTable.Border = Rectangle.NO_BORDER;
upperTable.DefaultCell.Border = Rectangle.NO_BORDER;
upperTable.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;
upperTable.AddCell(new Phrase("some text", font3));
d.Add(upperTable);
Table lowerTable= new Table(1);
lowerTable.Border = Rectangle.NO_BORDER;
lowerTable.DefaultCell.Border = Rectangle.NO_BORDER;
lowerTable.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;
lowerTable.AddCell(new Phrase("some other text", font3));
d.Add(lowerTable);
Run Code Online (Sandbox Code Playgroud)
有人能告诉我如何在两个表之间添加垂直空间吗?
谢谢!
小智 13
请改用PdfPTable.它有属性SpacingBefore和SpacingAfter
例如:
PdfPTable upperTable = new PdfPTable(1);
upperTable.AddCell(new Phrase("some text", font3));
upperTable.SpacingAfter = 10f;
Run Code Online (Sandbox Code Playgroud)
        我找到了一个可行的解决方案...将新行作为前面字符串或后面字符串的一部分添加到我想要创建的空间中。例如:
Table upperTable = new Table(1);
upperTable.Border = Rectangle.NO_BORDER;
upperTable.DefaultCell.Border = Rectangle.NO_BORDER;
upperTable.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;
upperTable.AddCell(new Phrase("some text" + '\n', font3));
d.Add(upperTable);
Table lowerTable= new Table(1);
lowerTable.Border = Rectangle.NO_BORDER;
lowerTable.DefaultCell.Border = Rectangle.NO_BORDER;
lowerTable.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;
lowerTable.AddCell(new Phrase('\n' + "some other text", font3));
d.Add(lowerTable);
Run Code Online (Sandbox Code Playgroud)
会导致在和font3之间添加2 条高度由 定义的线"some text""some other text"
|   归档时间:  |  
           
  |  
        
|   查看次数:  |  
           12988 次  |  
        
|   最近记录:  |