在iTextSharp中的表旁边添加图像

时间:2014-07-27 00:03:09

标签: c# itextsharp

我想在没有换行符的情况下在表格旁边添加图片。我有以下代码:

iTextSharp.text.Font font = new iTextSharp.text.Font(FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.NORMAL));
iTextSharp.text.Font fontbold = new iTextSharp.text.Font(FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.BOLD));                                       


PdfPTable tkunde = new PdfPTable(1);
tkunde.WidthPercentage = 30;
tkunde.HorizontalAlignment = Element.ALIGN_LEFT;                                   

PdfPCell labkunNavn = new PdfPCell(new Phrase(navnn, fontbold));
labkunNavn.PaddingTop = 2f;
labkunNavn.HorizontalAlignment = Element.ALIGN_LEFT;
labkunNavn.Border = 0;
tkunde.AddCell(labkunNavn);

PdfPCell labkunAdresse = new PdfPCell(new Phrase(adresse, font));
labkunAdresse.PaddingTop = 2f;
labkunAdresse.HorizontalAlignment = Element.ALIGN_LEFT;
labkunAdresse.Border = 0;
tkunde.AddCell(labkunAdresse);

PdfPCell labkunPost = new PdfPCell(new Phrase(postnr + " " + område, font));
labkunPost.PaddingTop = 2f;
labkunPost.HorizontalAlignment = Element.ALIGN_LEFT;
labkunPost.Border = 0;
tkunde.AddCell(labkunPost);

doc.Add(tkunde);

iTextSharp.text.Image png = iTextSharp.text.Image.GetInstance(@"C:\Users\Osman\Desktop\download.jpg");
png.WidthPercentage = 10;
png.ScalePercent(50F);
png.Alignment = Element.ALIGN_RIGHT;

doc.Add(png);

但它会在表格下方添加图片,如下图链接所示:

http://postimg.org/image/z9rr0dk5p/4289a76a/

我希望布局是这样的:

http://postimg.org/image/3yae8w6q3/42ddcd80/

我如何实现这一目标?

提前致谢

0 个答案:

没有答案