2015-12-09 67 views
0

在使用itextsharp生成的pdf中,在C#中的表格上完成的格式不可見。使用itextsharp生成的pdf中的C#表格中的格式不可見

我做如下格式:

Table table = new Table(); 
table.BorderStyle = BorderStyle.Solid; 
table.Style.Add("width", "696"); 
table.BorderStyle = BorderStyle.Solid; 
TableRow row = new TableRow(); 
TableCell cell = new TableCell(); 
cell.BorderStyle = BorderStyle.Solid; 
Unit ut = new Unit(2); 
cell.BorderWidth = ut; 
cell.BorderColor = Color.Black; 

但仍然沒有任何格式生成我的PDF。 我的表格以pdf格式顯示。但是不應用格式。

有什麼想法?

+2

我沒有看到任何iTextSharp的在你的代碼。 –

+1

這是一個ASP.Net「表」或iTextSharp「表」嗎?如果是後者,請確保使用'PdfPTable'代替。 –

回答

0

看來你想添加一個黑色邊框,並設置表格寬度696

PdfPTable table = new PdfPTable(1); 
table.TotalWidth = 696f; 
PdfPCell cell = new PdfPCell(new Phrase("Hello World!", new Font(Font.ARIAL, 12f, Font.NORMAL, Color.BLACK))); 
cell.BorderColor = new Color(0,0,0); 
cell.Border = Rectangle.LEFT_BORDER | Rectangle.RIGHT_BORDER; 
cell.BorderWidthLeft = 2f; 
cell.BorderWidthRight = 2f; 
table.AddCell(cell); 
相關問題