C# 在PDF中创建不同大小和列的表

C# 在PDF中创建不同大小和列的表,c#,itextsharp,C#,Itextsharp,如何使用C#中的itextSharp在PDF中创建不同列数、大小的表 表1) 表2) 看起来一定像 Column1 Column2 Column3 Column4 Column5 Column6 Col1 Col2 Col3 像这样的 Document doc = new Document(PageSize.A4); PdfPTable aTable = new P

如何使用C#中的itextSharp在PDF中创建不同列数、大小的表

表1)

表2)

看起来一定像

Column1     Column2     Column3     Column4     Column5     Column6
Col1        Col2        Col3
像这样的

    Document doc        = new Document(PageSize.A4);

    PdfPTable aTable                = new PdfPTable(6);
    aTable.HorizontalAlignment      = Element.ALIGN_LEFT;
    aTable.WidthPercentage          = 100;
    aTable.AddCell("Column 1");
    aTable.AddCell("Column 2");
    aTable.AddCell("Column 3");
    aTable.AddCell("Column 4");
    aTable.AddCell("Column 5");
    aTable.AddCell("Column 6");

    doc.Add(aTable);

    PdfPTable tp                    = new PdfPTable(3);
    tp.HorizontalAlignment          = Element.ALIGN_LEFT;
    tp.WidthPercentage              = 50;
    //tp.SetWidths(new []{60f, 20f, 20f});
    tp.AddCell("Col 1");
    tp.AddCell("Col 2");
    tp.AddCell("Col 3");

    doc.Add(tp);

显示代码,你尝试了什么?????
Column1     Column2     Column3     Column4     Column5     Column6
Col1        Col2        Col3
    Document doc        = new Document(PageSize.A4);

    PdfPTable aTable                = new PdfPTable(6);
    aTable.HorizontalAlignment      = Element.ALIGN_LEFT;
    aTable.WidthPercentage          = 100;
    aTable.AddCell("Column 1");
    aTable.AddCell("Column 2");
    aTable.AddCell("Column 3");
    aTable.AddCell("Column 4");
    aTable.AddCell("Column 5");
    aTable.AddCell("Column 6");

    doc.Add(aTable);

    PdfPTable tp                    = new PdfPTable(3);
    tp.HorizontalAlignment          = Element.ALIGN_LEFT;
    tp.WidthPercentage              = 50;
    //tp.SetWidths(new []{60f, 20f, 20f});
    tp.AddCell("Col 1");
    tp.AddCell("Col 2");
    tp.AddCell("Col 3");

    doc.Add(tp);