2010-07-10 74 views
0

希望它看起来像这样。然后我打算在每张表格中放入条形码。任何帮助表示赞赏。itextsharp在页面上生成三列两行表格

_________ ________ ______ 
|  | |  | |  | 
|  | |  | |  | 
|  | |  | |  | 
|  | |  | |  | 
--------- -------- -------- 
_________ ________ ______ 
|  | |  | |  | 
|  | |  | |  | 
|  | |  | |  | 
|  | |  | |  | 
--------- -------- -------- 

回答

0

希望下面的代码有帮助...

Document document = new Document(rect, marginLeft, marginRight, marginTop, marginBottom); 

int tableColumns = 3; 
Table aTable = new Table(tableColumns); 
int row = 1; 
int col = 0; 
foreach (Barcode s in codeslist) 
{ 
    // Create new barcode 
    Image imageCode128 = GetImageCode128(s); 

    // Create a new cell to host the barcode image 
    Cell cell = new Cell(); 
    cell.Add(imageCode128); 
    aTable.AddCell(cell,row,col); 
    if (col == tableColumns-1) 
    { 
     col = 0; 
     row ++; 
    } 
    else col++; 
} 

// Add the completed table to the Document and close it. 
document.Add(aTable); 

document.Close();