Adding images side by side in pdf using itextsharp
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 :
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
精彩评论