Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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);
like image 200
Toni Avatar asked Jun 05 '15 07:06

Toni


People also ask

How to set image position in Pdf?

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.

How do you align two paragraphs to the left and right on the same line in Java?

Chunk glue = new Chunk(new VerticalPositionMark()); Paragraph p = new Paragraph("Text to the left"); p. add(new Chunk(glue));

What is chunk in IText?

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.


1 Answers

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);
like image 160
Toni Avatar answered Sep 30 '22 10:09

Toni