但是像桌子一样设计我不知道如何制作嵌套表并删除不需要的行......任何人都可以帮我解决这个问题吗?我们可以为10列做自动换行吗?我添加了截图。
PdfPTable pdfMastertable = new PdfPTable(10);
PdfPCell CalibrationContent = new PdfPCell(FormatPhrase("", 8, Font.NORMAL, BaseColor.BLACK));
CalibrationContent.Colspan = 6;
CalibrationContent.BackgroundColor = new BaseColor(255, 191, 0);
CalibrationContent.NoWrap = true;
CalibrationContent.HorizontalAlignment = Element.ALIGN_CENTER;
pdfMastertable.AddCell(CalibrationContent);
CalibrationContent = new PdfPCell(FormatPhrase("Approved By", 8, Font.NORMAL, BaseColor.BLACK));
CalibrationContent.Colspan = 2;
CalibrationContent.BackgroundColor = new BaseColor(255, 191, 0);
CalibrationContent.NoWrap = true;
CalibrationContent.HorizontalAlignment = Element.ALIGN_CENTER;
pdfMastertable.AddCell(CalibrationContent);
CalibrationContent = new PdfPCell(FormatPhrase("Sign", 8, Font.NORMAL, BaseColor.BLACK));
CalibrationContent.Colspan = 2;
CalibrationContent.BackgroundColor = new BaseColor(255, 191, 0);
CalibrationContent.NoWrap = true;
CalibrationContent.HorizontalAlignment = Element.ALIGN_CENTER;
pdfMastertable.AddCell(CalibrationContent);
PdfPCell cell = new PdfPCell(new Phrase("The following measuring instruments have been tested as below with result"));
cell.Colspan = 10;
cell.HorizontalAlignment = 1;
pdfMastertable.AddCell(cell);
pdfMastertable.DefaultCell.Padding = 10;
pdfMastertable.WidthPercentage = 96;
pdfMastertable.DefaultCell.BorderWidth = 1;
pdfMastertable.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT;
pdfMastertable.DefaultCell.VerticalAlignment = Element.ALIGN_BOTTOM;
pdfMastertable.DefaultCell.MinimumHeight = 40.0F;
pdfMastertable.HorizontalAlignment = 1;
Single[] widths10 = { 0.4F, 0.4F, 0.4F, 0.4F, 0.4F, 0.4F, 0.4F, 0.4F, 0.4F, 0.4F };
pdfMastertable.SetWidths(widths10);
CalibrationContent = new PdfPCell(FormatPhrase("Month Of Test", 8, Font.NORMAL, BaseColor.BLACK));
CalibrationContent.Colspan = 1;
CalibrationContent.BackgroundColor = new BaseColor(255, 191, 0);
CalibrationContent.NoWrap = true;
CalibrationContent.HorizontalAlignment = Element.ALIGN_CENTER;
pdfMastertable.AddCell(CalibrationContent);
CalibrationContent = new PdfPCell(FormatPhrase("Date Of Test", 8, Font.NORMAL, BaseColor.BLACK));
CalibrationContent.Colspan = 1;
CalibrationContent.BackgroundColor = new BaseColor(255, 191, 0);
CalibrationContent.NoWrap = true;
CalibrationContent.HorizontalAlignment = Element.ALIGN_CENTER;
pdfMastertable.AddCell(CalibrationContent);
CalibrationContent = new PdfPCell(FormatPhrase("Instrument Type", 8, Font.NORMAL, BaseColor.BLACK));
CalibrationContent.Colspan = 1;
CalibrationContent.BackgroundColor = new BaseColor(255, 191, 0);
CalibrationContent.NoWrap = true;
CalibrationContent.HorizontalAlignment = Element.ALIGN_CENTER;
pdfMastertable.AddCell(CalibrationContent);
CalibrationContent = new PdfPCell(FormatPhrase("Asset Id & Serial No", 8, Font.NORMAL, BaseColor.BLACK));
CalibrationContent.Colspan = 1;
CalibrationContent.BackgroundColor = new BaseColor(255, 191, 0);
CalibrationContent.NoWrap = true;
CalibrationContent.HorizontalAlignment = Element.ALIGN_CENTER;
pdfMastertable.AddCell(CalibrationContent);
CalibrationContent = new PdfPCell(FormatPhrase("Manufacturer", 8, Font.NORMAL, BaseColor.BLACK));
CalibrationContent.Colspan = 1;
CalibrationContent.BackgroundColor = new BaseColor(255, 191, 0);
CalibrationContent.NoWrap = true;
CalibrationContent.HorizontalAlignment = Element.ALIGN_CENTER;
pdfMastertable.AddCell(CalibrationContent);
CalibrationContent = new PdfPCell(FormatPhrase("Calibration Type", 8, Font.NORMAL, BaseColor.BLACK));
CalibrationContent.Colspan = 1;
CalibrationContent.BackgroundColor = new BaseColor(255, 191, 0);
CalibrationContent.NoWrap = true;
CalibrationContent.HorizontalAlignment = Element.ALIGN_CENTER;
pdfMastertable.AddCell(CalibrationContent);
CalibrationContent = new PdfPCell(FormatPhrase("Result", 8, Font.NORMAL, BaseColor.BLACK));
CalibrationContent.Colspan = 1;
CalibrationContent.BackgroundColor = new BaseColor(255, 191, 0);
CalibrationContent.NoWrap = true;
CalibrationContent.HorizontalAlignment = Element.ALIGN_CENTER;
pdfMastertable.AddCell(CalibrationContent);
CalibrationContent = new PdfPCell(FormatPhrase("Room Temp, Humidity", 8, Font.NORMAL, BaseColor.BLACK));
CalibrationContent.Colspan = 1;
CalibrationContent.BackgroundColor = new BaseColor(255, 191, 0);
CalibrationContent.NoWrap = true;
CalibrationContent.HorizontalAlignment = Element.ALIGN_CENTER;
pdfMastertable.AddCell(CalibrationContent);
CalibrationContent = new PdfPCell(FormatPhrase("Comments", 8, Font.NORMAL, BaseColor.BLACK));
CalibrationContent.Colspan = 1;
CalibrationContent.BackgroundColor = new BaseColor(255, 191, 0);
CalibrationContent.NoWrap = true;
CalibrationContent.HorizontalAlignment = Element.ALIGN_CENTER;
pdfMastertable.AddCell(CalibrationContent);
CalibrationContent = new PdfPCell(FormatPhrase("Tested By", 8, Font.NORMAL, BaseColor.BLACK));
CalibrationContent.Colspan = 1;
CalibrationContent.BackgroundColor = new BaseColor(255, 191, 0);
CalibrationContent.NoWrap = true;
CalibrationContent.HorizontalAlignment = Element.ALIGN_CENTER;
pdfMastertable.AddCell(CalibrationContent);
pdfDoc.Add(pdfMastertable);