javaitext:图片下方的文本

javaitext:图片下方的文本,java,itext,pdfptable,Java,Itext,Pdfptable,在PdfPCell中,我想放置多个图像,并在每个图像下放置一个文本。 我尝试使用以下代码: private PdfPTable tabellaRighe() throws BadElementException, MalformedURLException, IOException, DocumentException { int[] cellWidth = {500, 95}; PdfPTable table = new PdfPTable(2); table.s

在PdfPCell中,我想放置多个图像,并在每个图像下放置一个文本。 我尝试使用以下代码:

   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);
  }
private PdfPTable tabellaRighe()抛出BadElementException、MalformedUrlexException、IOException、DocumentException{
int[]cellWidth={500,95};
PdfPTable=新的PdfPTable(2);
表.设置宽度(单元格宽度);
table.setTotalWidth(PageSize.A4.getWidth()-45);
表2.setLockedWidth(真);
PDFP细胞;
cell=新的PdfPCell();
单元格宽度(0);
第p段=新的第()段;
对于(int i=0;i<4;i++){
Image=Image.getInstance(imgNd);
图像缩放拟合(300135);
短语ph=新短语();
ph.add(新块(图像,0,0,真));
博士添加(“CIAO”);
p、 添加(ph);
}
细胞内微量元素(p);
表2.addCell(cell);
cell=新的PdfPCell();
单元格底部(1);
单元格左(1);
单元格右(1);
单元格顶部(1);
表2.addCell(cell);
}
但文本不在图像下方,而是向右移动。
如何将文本放在每个图像下方?

在文本前后添加
\n

ph.add("\nCIAO\n");

\n制作新品。

同时,感谢您的回复。问题是图像必须是内联的。