我正在使用 iTextsharp 从 C# 应用程序生成 PDF 文档。我有一个 PdfPTable 来显示一些表格数据。我在表格中的问题与另一段重叠。无论如何我可以将表格放在特定位置吗?然后下面是我的代码
PdfPTable objTable = new PdfPTable(6);
objTable.DefaultCell.Padding=1;
objTable.DefaultCell.BorderColor = new Color(123, 123, 163);
objTable.DefaultCell.Padding = 1;
float[] headerwidths = { 12,18,25,20,6,17 }; // percentage
objTable.SetWidths(headerwidths);
objTable.WidthPercentage = 80; // percentage
System.Drawing.Color objColor=System.Drawing.ColorTranslator.FromHtml("#EEEEEE");
PdfPCell objCell0 = new PdfPCell(new Phrase("SlNo"));
PdfPCell objCell1 = new PdfPCell(new Phrase("Date"));
PdfPCell objCell2 = new PdfPCell(new Phrase("Expense name"));
PdfPCell objCell3 = new PdfPCell(new Phrase("Budgeted value"));
PdfPCell objCell4 = new PdfPCell(new Phrase("Units"));
PdfPCell objCell5 = new PdfPCell(new Phrase("Total submitted"));
//Add child rows with data
List<SubmitExpenseItem> objItemList=objExpense.ExpenseChildItems;
foreach (SubmitExpenseItem expChildItem in objItemList)
{
slno++;
objTable.AddCell(new PdfPCell(new Phrase(slno.ToString())));
objTable.AddCell(new PdfPCell(new Phrase(expChildItem.SubmitDate.ToShortDateString())));
objTable.AddCell(new PdfPCell(new Phrase(expChildItem.ExpenseName)));
objTable.AddCell(new PdfPCell(new Phrase(expChildItem.BudgetValue.ToString())));
objTable.AddCell(new PdfPCell(new Phrase(expChildItem.Units.ToString())));
objTable.AddCell(new PdfPCell(new Phrase(expChildItem.ActualValue.ToString())));
}
objChildInfoPara.Add(objTable);
objDoc.Add(objMasterDetailsPara);//First para
objDoc.Add(objChildInfoPara);
现在我的第二个段落(objChildInfoPara)与第一个重叠
谁能告诉我如何摆脱这个问题?