Skip to content
Advertisement

iText: how to add a String to a cell

Hi guys I am an absolute beginner so go easy on me, why is this not working for me, I really do not understand why this is not working, but I am a beginner so if someone could correct this for me, I would really appreciate it. I am surprised that it does not work

JavaScript

My Error messege:

JavaScript

Advertisement

Answer

iText 7.0 had a method add(String) for Cell.

For iText 7.1, as documented in the API, a Cell takes only a block element or an image for its add() method. Block elements in iText are things like paragraphs, lists and divs.

You can wrap your String in a Paragraph:

JavaScript

For further differences between 7.0 and 7.1, it may be useful to take a look at the 7.1 migration guide, which also include this change:

com.itextpdf.layout.element.Cell#add(java.lang.String) has been removed, use a BlockElement such as Paragraph instead.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement