使用itextsharp在pdf单元格中创建pdf表

时间:2012-02-10 04:37:33

标签: c# itextsharp

我想在pdf单元格中创建一个pdftable。我很难创造它。请帮我创建它..

这是我的部分代码:

maintable = new PdfPTable(1);
        empdetright = new PdfPTable(9);
        maintable.TotalWidth = 310f;
        maintable.LockedWidth = true;

        int[] rightTblWidth= { 8, 8, 10,10,10,10,10,10,15};
        empdetright.SetWidths(rightTblWidth);

        cell = new PdfPCell(new Phrase("Month", fnt1));
        cell.HorizontalAlignment = Element.ALIGN_CENTER;
        empdetright.AddCell(cell);
        cell = new PdfPCell(new Phrase("Amount of Wages Rs.", fnt1));
        cell.HorizontalAlignment = Element.ALIGN_CENTER;
        empdetright.AddCell(cell);

        cell = new PdfPCell(new Phrase("Contribution", fnt1));
        cell.HorizontalAlignment = Element.ALIGN_CENTER;
        cell.Colspan = 4;
        empdetright.AddCell(cell);

        ( I want to create a table with in the Contribution cell )   

        //cell = new PdfPCell(new Phrase(":", fnt1));
        //cell.HorizontalAlignment = Element.ALIGN_CENTER;
        //empdetright.AddCell(cell);
        //cell = new PdfPCell(new Phrase("::", fnt1));
        //cell.HorizontalAlignment = Element.ALIGN_CENTER;
        //empdetright.AddCell(cell);
        //cell = new PdfPCell(new Phrase(":::", fnt1));
        //cell.HorizontalAlignment = Element.ALIGN_CENTER;
        //empdetright.AddCell(cell);

        cell = new PdfPCell(new Phrase("Refund of Advances", fnt1));
        cell.HorizontalAlignment = Element.ALIGN_CENTER;
        empdetright.AddCell(cell);
        cell = new PdfPCell(new Phrase("Non cont. services from ----- To----", fnt1));
        cell.HorizontalAlignment = Element.ALIGN_CENTER;
        empdetright.AddCell(cell);
        cell = new PdfPCell(new Phrase("Remarks", fnt1));
        cell.HorizontalAlignment = Element.ALIGN_CENTER;
        empdetright.AddCell(cell);

        cell = new PdfPCell(empdetright);
        maintable.AddCell(cell);
        doc.Add(maintable);

我在名称贡献中合并了四列。但我只需要一个在这个单元格中有三列的pdf表。如何创建它。请帮我创建它......

0 个答案:

没有答案