2012-02-23 24 views
16

मैं तालिका कक्ष का सीमा रंग कैसे सेट करूं? यहां मेरे पास कोड है:ITextSharp: सेट टेबल सेल सीमा रंग

// create and define table 
var table = new PdfPTable(8); 
table.HorizontalAlignment = Element.ALIGN_CENTER; 

//table.HeaderRows = 1; 

// the cell object 
PdfPCell cell; 
var f = FontFactory.GetFont("Tahoma", 11, Font.BOLD); 

cell = new PdfPCell(new Phrase("Source Review", f)); 
cell.BorderColorLeft = new BaseColor(255, 255, 255); 
cell.BorderColorRight = new iTextSharp.text.BaseColor(255, 255, 255); 
table.AddCell(cell); 

जैसा कि आप देख सकते हैं कि मैं रंग को दो अलग-अलग तरीकों से सेट कर रहा हूं और न ही काम कर रहा हूं। जब तालिका प्रदान की जाती है तो सीमा हमेशा काला होती है। मैं इसे कैसे ठीक करूं।

उत्तर

27

आप व्यक्ति सेल बॉर्डर गुण सेट जब आप या तो व्यक्तिगत रूप सभी सीमा रंग और चौड़ाई निर्धारित करने की आवश्यकता, या स्पष्ट रूप से true को UseVariableBorders गुण सेट। यह देखने के लिए इस उदाहरण का प्रयास करें कि मेरा क्या मतलब है:

PdfPTable table = new PdfPTable(1); 
PdfPCell cell = new PdfPCell(new Phrase("test 1")); 
cell.UseVariableBorders = true; 
cell.BorderColorLeft = BaseColor.BLUE; 
cell.BorderColorRight = BaseColor.ORANGE; 
table.AddCell(cell); 

cell = new PdfPCell(new Phrase("test 2")); 
cell.BorderColorLeft = BaseColor.RED; 
cell.BorderColorRight = BaseColor.GREEN; 
cell.BorderColorTop = BaseColor.PINK; 
cell.BorderColorBottom = BaseColor.YELLOW; 
cell.BorderWidthLeft = 1f; 
cell.BorderWidthRight = 1f; 
cell.BorderWidthTop = 1f; 
cell.BorderWidthBottom = 1f; 
table.AddCell(cell); 

cell = new PdfPCell(new Phrase("test 3")); 
cell.BorderColor = BaseColor.GREEN; 
table.AddCell(cell); 
संबंधित मुद्दे