Search code examples
imageitextalignment

How to align Image to right in iText?


I am adding image to a table cell. I want to position the image to the right of the cell.

I've tried this:

PdfPCell imagecell= new PdfPCell();
imagecell.add element(myImage);
imagecell.setHorizontalAlignment(Element.ALIGN_RIGHT);

Solution

  • Actually, I have got a solution for the question so thought it might be helpful to share it here.

    The image can be aligned to the right of the table cell by specifying the alignment property of the Image object as shown below:

    myImage.setAlignment(Image.ALIGN_RIGHT);