C# 使用itextsharp在pdf中并排添加图像

C# 使用itextsharp在pdf中并排添加图像,c#,pdf,itextsharp,C#,Pdf,Itextsharp,我正在使用itextsharp将一些数据写入pdf。我添加了2张图片。我使用了以下代码: iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(System.Windows.Forms.Application.StartupPath + "\\t.jpg"); iTextSharp.text.Image img2 = iTextSharp.text.Image.GetInstance(System.Windows.Form

我正在使用itextsharp将一些数据写入pdf。我添加了2张图片。我使用了以下代码:

 iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(System.Windows.Forms.Application.StartupPath + "\\t.jpg");
 iTextSharp.text.Image img2 = iTextSharp.text.Image.GetInstance(System.Windows.Forms.Application.StartupPath + "\\teiasLogo.jpg");
 pdfDocCreatePDF.Add(img);
 pdfDocCreatePDF.Add(img2);
我想看到他们这样:


因此,我不希望在图像之间有新行(\n),我希望有空格。我该怎么做?谢谢。

您可以使用PdfPTable来生成它。创建一个新表。然后可以将图像分配给每个单元格(边框为0)

 PdfPTable resimtable = new PdfPTable(2); // two colmns create tabble
 resimtable.WidthPercentage = 100f;//table %100 width
 iTextSharp.text.Image imgsag = iTextSharp.text.Image.GetInstance(Application.StartupPath+"/sagkulak.jpg");
iTextSharp.text.Image imgsol = iTextSharp.text.Image.GetInstance(Application.StartupPath + "/sagkulak.jpg");
resimtable.AddCell(imgsag);//Table One colmns added first image
resimtable.AddCell(imgsol);//Table two colmns added second image