2013-06-13 53 views
1

我需要使用itextsharp建立一個pdf。當然,我的問題是我不能使表格邊框寬度爲0px。我不想表或單元格邊框.. 我的代碼是問題與表格邊框,而在asp.net中使用itextsharp

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) 

它如何可以解決或者是有我的代碼中的任何錯誤...

+0

請提供示例PDF,說明問題並允許調查邊界的來源。 – mkl

回答

1

任何嘗試這兩個。

table.borderwidth= 0; 

OR

table.DefaultCell.BorderWidth = 0 
table.DefaultCell.Border = iText.Rectangle.NO_BORDER 

希望這有助於。請讓我知道這是否有效。由於我現在沒有安裝sharpxt,所以我無法測試它。

+0

它不起作用 – Sivajith

2

以前的答案几乎是正確的。

設置DefaultCell是好的,但它只適用於使用AddCell()string值或Phrase對象。如果您創建自己的PdfPCell,則需要如下所示:

image_header.Border = PdfPCell.NO_BORDER;