在iTextSharp中的两个表之间添加空格 [英] Add space between two tables in iTextSharp
本文介绍了在iTextSharp中的两个表之间添加空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
正如标题所说,我正在使用iTextSharp生成报告。我想在两个表之间添加一个空格,但我不知道如何。
Just as the title says, I'm using iTextSharp to generate a report. And I want to add a space between two tables, but I don't know how.
这是我的代码:
var boldFont = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 12);
PdfPTable table1 = new PdfPTable(2);
table1.WidthPercentage = 25;
table1.HorizontalAlignment = Element.ALIGN_LEFT;
table1.AddCell(new PdfPCell(new Paragraph("Factura No: ")));
table1.AddCell(new PdfPCell(new Paragraph("#1")));
table1.AddCell(new PdfPCell(new Paragraph("Tipo Fact: ")));
table1.AddCell(new PdfPCell(new Paragraph("Contado")));
table1.AddCell(new PdfPCell(new Paragraph("Fecha: ")));
table1.AddCell(new PdfPCell(new Paragraph("3/17/2017")));
table1.AddCell(new PdfPCell(new Paragraph("Cedula: ")));
table1.AddCell(new PdfPCell(new Paragraph("207080801")));
table1.AddCell(new PdfPCell(new Paragraph("Cliente: ")));
table1.AddCell(new PdfPCell(new Paragraph("Errol")));
//add space here
PdfPTable table2 = new PdfPTable(3);
table2.HorizontalAlignment = 1;
table2.WidthPercentage = 70;
table2.AddCell(new PdfPCell(new Paragraph("Producto", boldFont)));
table2.AddCell(new PdfPCell(new Paragraph("Cantidad", boldFont)));
table2.AddCell(new PdfPCell(new Paragraph("Subtotal", boldFont)));
table2.AddCell(new PdfPCell(new Paragraph("PDN130")));
table2.AddCell(new PdfPCell(new Paragraph("2")));
table2.AddCell(new PdfPCell(new Paragraph("18000")));
推荐答案
你可以使用 SpacingBefore
或< a href =http://itextsupport.com/apidocs/itext5/latest/com/itextpdf/text/Paragraph.html#spacingAfter =nofollow noreferrer> SpacingAfter
。
试试这样:
You can use SpacingBefore
or SpacingAfter
on the tables.
Try like this :
table1.SpacingBefore = 10f;
table1.SpacingAfter = 12.5f;
table2.SpacingBefore = 10f;
table2.SpacingAfter = 12.5f;
这篇关于在iTextSharp中的两个表之间添加空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文