在 itextsharp 中将单元格中心的文本与图像对齐

Align text in center of cell next to image in itexsharp

这是我的问题的直观图。

这是我生成该结果的代码。

public void intervencionHeaderLogo(string pictureURL,int width, int height)
    {
        iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(System.Web.HttpContext.Current.Server.MapPath(pictureURL));
        image.ScaleAbsolute(width, height);
        image.Alignment = 2;

        //Table
        PdfPTable table = new PdfPTable(1);

        PdfPCell cell = new PdfPCell();
        BaseFont bf = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
        iTextSharp.text.Font font = new iTextSharp.text.Font(bf, 20, iTextSharp.text.Font.NORMAL);
        Paragraph p = new Paragraph("Reporte de intervención", font);

        //Cell no 1
        cell = new PdfPCell();
        cell.Border = 0;
        cell.AddElement(p);
        cell.HorizontalAlignment = Element.ALIGN_CENTER;
        table.AddCell(cell);

        //Cell no 2
        cell = new PdfPCell();
        cell.Border = 0;
        cell.AddElement(image);
        table.AddCell(cell);

        //Add table to document    
        pdfDoc.Add(table);
    }

这是我想要的。

如有任何帮助,我们将不胜感激

我能够修复它,我犯了一个错误,我创建了一个 table 1,而我应该将它的大小设为 2。

    //Table
    PdfPTable table = new PdfPTable(2);

并且我在这样的段落中添加了这样的换行符

   Paragraph p = new Paragraph("\nReporte de intervención", font);