Я хочу добавить изображение и текст в одну строку, используя только одну ячейку.Я могу добавить изображение и текст в одну ячейку, но изображение появляется в новой строке, а не рядом с текстом
Ссылка на iText пример :
public static void main(String[] args) throws Exception { String dest = "sample.pdf"; String img1 = "sample.jpg"; File file = new File(dest); file.getParentFile().mkdirs(); PdfDocument pdfDoc = new PdfDocument(new PdfWriter(dest)); Document doc = new Document(pdfDoc); Table table = new Table(UnitValue.createPercentArray(new float[]{1, 2})); table.addCell(createImageCell(img1)); table.addCell(createTextCell("Some Text")); doc.add(table); doc.close(); } public static Cell createImageCell(String path) throws MalformedURLException { Image img = new Image(ImageDataFactory.create(path)); img.setWidth(UnitValue.createPercentValue(100)); Cell cell = new Cell().add(img); cell.setBorder(null); return cell; } public static Cell createTextCell(String text) { Cell cell = new Cell(); Paragraph p = new Paragraph(text); p.setTextAlignment(TextAlignment.RIGHT); cell.add(p).setVerticalAlignment(VerticalAlignment.BOTTOM); cell.setBorder(Border.NO_BORDER); return cell; }