2011-11-03 6 views
2

私のテキストが左側にあり、画像(QRCode)が右側(CSSの意味で)に浮かべられているフォーマットされたPdfPCellを作成しようとしています。私の現在のコードは画像を右に移動しますが、テキストは画像と同じ行ではない次の行にあります。セル内の画像を浮動させる方法 - iTextPDF

アイデア?

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); 

答えて

2

あなたはこれを試してみてください

img.Alignment = Image.TEXTWRAP | Image.ALIGN_RIGHT; 
0

img.setAlignment(Element.ALIGN_RIGHT); 

を交換してくださいすることができます。

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); 
関連する問題