Vertical spacing iTextSharp

I use iTextSharp to create some PDF files. I have two tables that have content, and I want to place some space between the two tables, for example, equivalent to 1 line of text (using the same font as the tables around the space).

Below is the code that I use to add two tables. I cannot figure out how to place vertical space between two tables.

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);

Can someone tell me how can I add vertical space between two tables?

Thanks!

+5
source share
2 answers

, ... , . :

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);

, font3, ​​ "some text" "some other text"

+2

PdfPTable. SpacingBefore SpacingAfter

:

PdfPTable upperTable = new PdfPTable(1);
upperTable.AddCell(new Phrase("some text", font3));
upperTable.SpacingAfter = 10f;
+12

All Articles