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);
Place an image or object into a PDFOpen the PDF in Acrobat, and then choose Tools > Edit PDF > Add Image . In the Open dialog box, locate the image file you want to place. Select the image file, and click Open. Click where you want to place the image, or click-drag to size the image as you place it.
Chunk glue = new Chunk(new VerticalPositionMark()); Paragraph p = new Paragraph("Text to the left"); p. add(new Chunk(glue));
Chunk class in IText represents the smallest possible "chunk" of text. A Chunk can contain as little as a single character, up to several sentences. Notice how sentence 1 and sentence 6 are printed ontop of each other. The IText Chunk object does not add line breaks, paragraph spacing or any other kind of spacing.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With