ciao!
sto usando iText per creare dei pdf.
devo aggiungere delle immagini, e sotto immagine un testo.
ho provato così:
e non ha funzionato benissimo.codice:private PdfPTable tabellaRighe() throws BadElementException, MalformedURLException, IOException, DocumentException { int[] cellWidth = {500, 95}; PdfPTable table = new PdfPTable(2); table.setWidths(cellWidth); table.setTotalWidth(PageSize.A4.getWidth() - 45); table.setLockedWidth(true); PdfPCell cell; cell = new PdfPCell(); cell.setBorderWidth(0); Paragraph p = new Paragraph(); for (int i = 0; i < 4; i++) { Image image = Image.getInstance(imgNd); image.scaleToFit(300, 135); Phrase ph = new Phrase(); ph.add(new Chunk(image, 0, 0, true)); ph.add("CIAO"); p.add(ph); } cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthBottom(1); cell.setBorderWidthLeft(1); cell.setBorderWidthRight(1); cell.setBorderWidthTop(1); table.addCell(cell); return table; }
il testo non è proprio sotto all'immagine.
come posso fare??

Rispondi quotando