Reputation: 1211
i need to build a pdf using itextsharp. curently my issue is i cannot make the table border width to 0px. i dont want the table or cell border.. my code is
Document Doc = new Document();
//PdfWriter.GetInstance(Doc, new FileStream(Environment.GetFolderPath
//(Environment.SpecialFolder.Desktop) + "\\TTS_Bill.pdf", FileMode.Create));
PdfWriter.GetInstance(Doc, new FileStream(Server.MapPath("~/DMSDOC/DMS_doc.pdf"), FileMode.Create));
Doc.Open();
PdfPTable table = new PdfPTable(1);
table.DefaultCell.Border = PdfPCell.NO_BORDER;
table.TotalWidth = 400f;
table.LockedWidth = true;
iTextSharp.text.Image logo = iTextSharp.text.Image.GetInstance("~/img/val verde hospital.png");
logo.ScaleAbsolute(40, 40);
PdfPCell image_header = new PdfPCell(logo);
image_header.HorizontalAlignment = Element.ALIGN_CENTER;
table.AddCell(image_header)
how can it be solved or is there any mistake in my code...
Upvotes: 1
Views: 5310
Reputation: 77528
The previous answer was almost correct.
Setting the DefaultCell
is fine, but it only works if you use AddCell()
with a string
value or a Phrase
object. If you create your own PdfPCell
, you need something like this:
image_header.Border = PdfPCell.NO_BORDER;
Upvotes: 2
Reputation: 3117
Try any of these two.
table.borderwidth= 0;
OR
table.DefaultCell.BorderWidth = 0
table.DefaultCell.Border = iText.Rectangle.NO_BORDER
Hope this helps. Please let me know if this works. As I don't have itext sharp installed now, I can't test this.
Upvotes: 1