簡體   English   中英

圖像上的Horizo​​ntalAlignment在itextsharp中的PdfPCell中不起作用

[英]HorizontalAlignment on image not working in PdfPCell in itextsharp

我在PdfPCell中添加一個圖像,我希望它是中心對齊的。 為此我使用了以下代碼,但它不起作用

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

請問你能告訴我哪里錯了

謝謝

您需要在圖像上設置對齊方式,而不是單元格:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM