开发者

Adding images side by side in pdf using itextsharp

开发者 https://www.devze.com 2023-04-08 14:59 出处:网络
I am writing some data to the pdf using itextsharp. I am adding 2 images. I used this code: iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(System.Windows.Forms.Application.StartupPath

I am writing some data to the pdf using itextsharp. I am adding 2 images. I used this code:

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

I want to see them like that :

Adding images side by side in pdf using itextsharp

As a re开发者_开发百科sult I don't want new line ( \n ) between the images, I want spaces. How can I do that? Thanks..


You can produce that by using PdfPTable. Create a new table. Then you can assign your images to each cell (with border=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
0

精彩评论

暂无评论...
验证码 换一张
取 消