在iTextSharp中的两个表之间添加空格

时间:2017-03-17 23:25:57

标签: c# winforms itext

正如标题所说,我正在使用iTextSharp生成报告。我想在两个表之间添加一个空格,但我不知道如何。

这是我的代码:

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

2 个答案:

答案 0 :(得分:2)

您可以在表格中使用SpacingBeforeSpacingAfter 试试这样:

<target if="netbeans.home" name="-run-deploy-nb">
    <nbdeploy clientUrlPart="${client.urlPart}" debugmode="false" forceRedeploy="${forceRedeploy}"/>
</target>

答案 1 :(得分:0)

 PdfPTable tblAcNo8 = new PdfPTable(4);
            float[] colWidthsaccing8 = { 150, 250, 30, 500 };
            tblAcNo8.SetWidths(colWidthsaccing8);
            tblAcNo8.SpacingBefore = 10f;
            PdfPCell celladdingo8;

            celladdingo8 = new PdfPCell(new Phrase("", TableFontmini_ARBold8Nor));
            celladdingo8.HorizontalAlignment = 0;
            celladdingo5.BorderWidthRight = 0;
            celladdingo5.BorderWidthLeft = 0;
            celladdingo5.BorderWidthTop = 0;
            celladdingo5.BorderWidthBottom = 0;
            tblAcNo8.AddCell(celladdingo8);