You can change the borders of the cells so that they display only vertical lines. How to do this depends on how you add cells to the table.
These are two approaches:
1. You explicitly create PdfPCell objects:
PdfPCell cell = new PdfPCell (); cell.AddElement (new paragraph ("my content")); cell.Border = PdfPCell.LEFT; table.AddCell (cell);
. :
cell.Border = PdfPCell.LEFT | PdfPCell.RIGHT;
2. PdfPCell:
PdfPCell , iTextSharp . DefaultCell, PdfPTable, :
table.DefaultCell.Border = Rectangle.LEFT | Rectangle.RIGHT;
table.addCell("cell 1");
table.addCell("cell 2");
table.addCell("cell 3");
, . , , .
. iTextSharp
:
PdfPTable table = new PdfPTable(5);
table.TotalWidth = 510f;
table.LockedWidth = true;
table.SpacingBefore = 10f;
table.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT;
table.DefaultCell.Border = PdfPCell.LEFT | PdfPCell.RIGHT;
table.AddCell(new Phrase(" SL.NO", font1));
table.AddCell(new Phrase(" SUBJECTS", font1));
table.AddCell(new Phrase(" MARKS", font1));
table.AddCell(new Phrase(" MAX MARK", font1));
table.AddCell(new Phrase(" CLASS AVG", font1));
Doc.Add(table);
DefaultCell . Phrase : new Phrase(new Phrase("content")).