2011-09-26 94 views
0

我使用itextsharp将一些数据写入pdf。我添加了2张图片。我用这个代码:使用itextsharp以pdf格式并排添加图像

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); 

我希望看到他们这样的: image

因此,我不希望图像之间的新行(\ n)的,我想空间。我怎样才能做到这一点?谢谢..

回答

1

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

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