简体   繁体   中英

HorizontalAlignment on image not working in PdfPCell in itextsharp

I am adding a image in PdfPCell and i want that to be center aligned. For that i used following code but its not working

            PdfPTable Outertable = new PdfPTable(1);
            PdfPCell celltop = new PdfPCell(new Phrase(" "));
            iTextSharp.text.Image img10 = iTextSharp.text.Image.GetInstance(@"F:\TestPDFGenerator\TestPDFGenerator\TestPDFGenerator\Sumit.JPG");
            img10.ScaleAbsolute(50, 1);
            celltop.AddElement(img10);
            celltop.HorizontalAlignment = Element.ALIGN_CENTER;
            Outertable.AddCell(celltop);

please can you tell where i am wrong

Thanks

您需要在图像上设置对齐方式,而不是单元格:

img10.Alignment = iTextSharp.text.Image.ALIGN_CENTER;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM