2017-03-17 149 views
2

正如標題所示,我使用iTextSharp生成報告。我想在兩張桌子之間加一個空格,但我不知道如何。在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"))); 

回答

1

您可以在表上使用SpacingBeforeSpacingAfter
請試試這個:

table1.SpacingBefore = 10f; 
table1.SpacingAfter = 12.5f; 
table2.SpacingBefore = 10f; 
table2.SpacingAfter = 12.5f; 
+0

太棒了!這是我需要的,謝謝 –

+0

很高興聽到! –