如何在 pdf 的一行中添加 3 个 imagecell?

how to add 3 imagecell in a single line in pdf?

我有 3 个单元格,其中包含图像和文本。我想将这 3 个单元格排成一行(水平)。现在它是垂直的,我该怎么做,还想减小字体大小 also.plese 帮助我。我的密码是

 PdfPTable BarCodeTable = new PdfPTable(3);
 BarCodeTable.SetTotalWidth(new float[] { 100,100,100});
 Barcode128 code128 = new Barcode128();
            code128.CodeType = Barcode.CODE128_UCC;
            int count = 1;
            foreach (DataListItem dli in dl.Items)
            {

                string productID11 = ((Label)dli.FindControl("lblBarCode")).Text;
                string studid1 = ((Label)dli.FindControl("lblStudCode")).Text;
                if (count == 1)
                {
                    code128.Code = "*" + productID11 + "*";
                    iTextSharp.text.Image image128 = code128.CreateImageWithBarcode(cb, null, null);
                    cell.AddElement(image128);
                    Paragraph p = new Paragraph("" + studid1 + "");
                    p.Alignment = Element.ALIGN_CENTER;
                    cell.AddElement(p);
                    count++;
                }
                else if(count==2)
                {
                    code128.Code = "*" + productID11 + "*";
                    iTextSharp.text.Image image128 = code128.CreateImageWithBarcode(cb, null, null);
                    cell.AddElement(image128);
                    Paragraph p = new Paragraph("" + studid1 + "");
                    p.Alignment = Element.ALIGN_CENTER;
                    cell.AddElement(p);
                    count++;
                }
                else if (count == 3)
                {
                    code128.Code = "*" + productID11 + "*";
                    iTextSharp.text.Image image128 = code128.CreateImageWithBarcode(cb, null, null);
                    cell.AddElement(image128);
                    Paragraph p = new Paragraph("" + studid1 + "");
                    p.Alignment = Element.ALIGN_CENTER;
                    cell.AddElement(p);
                    count = 1;
                }

                BarCodeTable.AddCell(cell);
            }

            doc.Add(BarCodeTable);

如何在一行中显示 3 个单元格? 预期输出是

或者让我知道我可以将此单元格添加到另一个 pdf table 单元格吗?

我自己找到了答案..看一下,也许对某人有帮助。

  int count=1;
 foreach (DataListItem dli in dl.Items)
    {

     string barcode = ((Label)dli.FindControl("lblBarCode")).Text;
     string studcode = ((Label)dli.FindControl("lblStudCode")).Text;
     if (count == 1)
      {
         PdfPCell cell0 = new PdfPCell();
         code128.Code = "*" + barcode + "*";
         iTextSharp.text.Image image128111 = code128.CreateImageWithBarcode(cb, null, null);
         cell0.AddElement(image128111);
         Paragraph p = new Paragraph("" + studcode + "");
         p.Alignment = Element.ALIGN_CENTER;
         cell0.AddElement(p);
         BarCodeTable.AddCell(cell0);
         BarCodeTable.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;
         BarCodeTable.AddCell(new Phrase(new Phrase("", times11)));
         count++;
      }
      else if (count == 2)
       {
          PdfPCell cell1 = new PdfPCell();
          code128.Code = "*" + barcode + "*";
          iTextSharp.text.Image image1281 = code128.CreateImageWithBarcode(cb, null, null);
          cell1.AddElement(image1281);
          Paragraph p1 = new Paragraph("" + studcode + "");
          p1.Alignment = Element.ALIGN_CENTER;
          cell1.AddElement(p1);
          BarCodeTable.AddCell(cell1);
          BarCodeTable.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;
          BarCodeTable.AddCell(new Phrase(new Phrase("", times11)));
          count++;
        }
       else if(count==3)
        {
            PdfPCell cell2 = new PdfPCell();
            code128.Code = "*" + barcode + "*";
            iTextSharp.text.Image image1282 = code128.CreateImageWithBarcode(cb, null, null);
            cell2.AddElement(image1282);
            Paragraph p2 = new Paragraph("" + studcode + "");
            p2.Alignment = Element.ALIGN_CENTER;
            cell2.AddElement(p2);
            BarCodeTable.AddCell(cell2);
            count = 1;
         }
       }
     doc.Add(BarCodeTable);

输出会是这样的,