Reputation: 357
I am trying to create a formatted PdfPCell where my text is on the left and an image(QRCode) is "floated" (in the css sense) to the right. My current code moves the image to the right but the text is on the next line not the same line as the image.
Ideas?
PdfPCell cell = new PdfPCell();
Paragraph p = new Paragraph();
p.add(new Paragraph("Ciao Baby",RESTNAME));
BarcodeQRCode qrcode = new BarcodeQRCode("http://www.tvfoodmaps.com", 72, 72, null);
Image img = qrcode.getImage();
img.scaleToFit(32,32);
img.setAlignment(Element.ALIGN_RIGHT);
cell.addElement(img);
cell.addElement(p);
Upvotes: 2
Views: 3825
Reputation:
Try this.
Phrase phrase = new Phrase("Ciao Baby",RESTNAME);
BarcodeQRCode qrcode = new BarcodeQRCode("http://www.tvfoodmaps.com", 72, 72, null);
Image img = qrcode.getImage();
img.scaleToFit(32,32);
phrase.add(new Phrase(new Chunk(img, 0, 0)));
cell.addElement(phrase);
Upvotes: 0
Reputation: 890
You can try replacing
img.setAlignment(Element.ALIGN_RIGHT);
with
img.Alignment = Image.TEXTWRAP | Image.ALIGN_RIGHT;
Upvotes: 3