如何在iText中将图像对齐?

Ton*_*oni 4 image alignment itext

我正在将图像添加到表格单元格中.我想将图像放在单元格的右侧.

我试过这个:

PdfPCell imagecell= new PdfPCell();
imagecell.add element(myImage);
imagecell.setHorizontalAlignment(Element.ALIGN_RIGHT);
Run Code Online (Sandbox Code Playgroud)

Ton*_*oni 10

实际上,我有一个问题的解决方案,所以认为在这里分享它可能会有所帮助.

通过指定Image对象的alignment属性,可以将图像对齐到表格单元格的右侧,如下所示:

myImage.setAlignment(Image.ALIGN_RIGHT);
Run Code Online (Sandbox Code Playgroud)