0
我想建立一个pdf,其中我必须添加一个没有边框的表格,我这样做,但有没有更好的方法来做到这一点? 我的代码是这样的:如何在itext中隐藏表格的边框在asp.net MVC vs12中shrp pdf?
PdfPTable row1 = new PdfPTable(4);
row1.TotalWidth = 350f;
row1.LockedWidth = true;
int[] intTblWidth1 = { 20,50,20,40 };
row1.SetWidths(intTblWidth1);
row1.SpacingBefore = 20f;
row1.HorizontalAlignment = Element.ALIGN_LEFT;
PdfPCell cel = new PdfPCell(new Phrase("Ordered By: ", bodyFont));
cel.Colspan = 1;
cel.Border = 0;
cel.HorizontalAlignment = 0;
row1.AddCell(cel);
PdfPCell cel1 = new PdfPCell(new Phrase(_requester, titleFont));
cel1.Border = 0;
cel1.HorizontalAlignment = 0;
cel1.VerticalAlignment = 0;
row1.AddCell(cel1);
PdfPCell cel2 = new PdfPCell(new Phrase("Order #: ", bodyFont));
cel2.Colspan = 1;
cel2.Border = 0;
cel2.HorizontalAlignment = 0;
row1.AddCell(cel2);
PdfPCell cel3 = new PdfPCell(new Phrase(_orderNumber, titleFont));
cel3.Colspan = 1;
cel3.Border = 0;
cel3.HorizontalAlignment = 0;
row1.AddCell(cel3);
doc.Add(row1);
我使用新表中创建新行。
,如果我这样做: -
PdfPTable table = new PdfPTable(3);
PdfPCell cell = new PdfPCell(new Phrase("Header spanning 3 columns"));
cell.Colspan = 3;
cell.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right
table.AddCell(cell);
table.AddCell("Col 1 Row 1");
table.AddCell("Col 2 Row 1");
table.AddCell("Col 3 Row 1");
table.AddCell("Col 1 Row 2");
table.AddCell("Col 2 Row 2");
table.AddCell("Col 3 Row 2");
doc.Add(table);
我不能够隐藏表格的边框,而我不想表中的任何边界线。 我必须生成一个动态的pdf。任何建议将不胜感激,我会标记你的答案,如果它为我工作。预先感谢您;)愉快的编码。
第一个不工作,第二个我必须设置每个单元格边框,并且在我的pdf表格中有更多的100个cloumns –
是否有任何方法来设置表格+单元格边框false 。我有一个想法,如果我设置表边框颜色=白色,因为背景颜色是白色的。但不知道如何设置它。我已经尝试table.defaultCell.BorderColor = BaseColor.white;但它不起作用 –
你在那里@Robin Rizvi –