在特定行之后跳过额外的行

时间:2015-02-11 06:06:35

标签: c# .net itextsharp itext

我有一个有3列的表,它有大约10行。但我想要做的是在特定行之后跳过额外的行。

这是我的代码;

Paragraph paragraphTable3 = new Paragraph();
paragraphTable3.SpacingBefore = 20f;
paragraphTable3.SpacingAfter = 10f;

PdfPTable third_table = new PdfPTable(3);
third_table.TotalWidth = 560f;
third_table.LockedWidth = true;
third_table.SetWidths(new float[] { 2.4f,0.1f, 6.6f });

third_table.AddCell(new PdfPCell(new Phrase("Responsibilities Held ", other)) { BorderWidth = 0 });
third_table.AddCell(new PdfPCell(new Phrase(": ", other)) { BorderWidth = 0 });
third_table.AddCell(new PdfPCell(new Phrase( Responsibilities_held, other)) { BorderWidth = 0 });

third_table.AddCell(new PdfPCell(new Phrase("Description of Work Done", other)) { BorderWidth = 0 });
third_table.AddCell(new PdfPCell(new Phrase(": ", other)) { BorderWidth = 0 });
third_table.AddCell(new PdfPCell(new Phrase( Description_of_work_done, other)) { BorderWidth = 0 });

我得到这样的输出;

Responsibilities Held           : Blah bluh bluh bluh bluh ............................
                                  bluh ..........bluh ...

Description of Work Done        : Blu....................................h..............
                                  bluh.........................

Present Address                 : Blu....................................h..............
                                  bluh.........................Extra space after here

Additional Qualifications       : Blu....................................h..............
                                  bluh.........................

我想在现场地址

之后添加额外的空间

请帮帮我.... 谢谢

2 个答案:

答案 0 :(得分:1)

如果要在两行之间添加一些额外空格,为什么不添加一个固定高度的额外(空)行?

我带了你的代码片段,在表格中添加了两行,并在这两行之间添加了一个额外的单元格,其中包含colspan 3。我将此行的高度定义为30个用户单位(对应30个点):

PdfPTable third_table = new PdfPTable(3);
third_table.TotalWidth = 560f;
third_table.LockedWidth = true;
third_table.SetWidths(new float[] { 2.4f,0.1f, 6.6f });

third_table.AddCell(new PdfPCell(new Phrase("Responsibilities Held ", other)) { BorderWidth = 0 });
third_table.AddCell(new PdfPCell(new Phrase(": ", other)) { BorderWidth = 0 });
third_table.AddCell(new PdfPCell(new Phrase( Responsibilities_held, other)) { BorderWidth = 0 });

PdfPCell cell = new PdfPCell();
cell.Colspan = 3;
cell.FixedHeight = 30.0f;
third_table.AddCell(cell);

third_table.AddCell(new PdfPCell(new Phrase("Description of Work Done", other)) { BorderWidth = 0 });
third_table.AddCell(new PdfPCell(new Phrase(": ", other)) { BorderWidth = 0 });
third_table.AddCell(new PdfPCell(new Phrase( Description_of_work_done, other)) { BorderWidth = 0 });

答案 1 :(得分:0)

你可以像这样使用PaddingBottom作为单元格属性。

new PdfPCell(new Phrase("Responsibilities Held ", other)) { BorderWidth = 0, PaddingBottom = 10f }