Search code examples
javafontsitextcellrtf

table cell font in RTF with lowagie Document


I am trying to create RTF document with tables with empty cells.

I use the com.lowagie.text.rtf.* package in java.

The font of the empty cells are all Times New Roman size 12.

How can I set the font of the empty cells to a different Font?

I have used RtfCell cellSpacer = new RtfCell(new Phrase("", new RtfFont("Arial", 9, RtfFont.NORMAL))); but because the string "" is empty the font doesn't take effect. When the "" is filled with something except a space the font does take effect.

Thank you.


Solution

  • A solution to this problem is that the space must be given as a Non Breaking space to the Phrase constructor!

    String nbs = "\u00A0";

    RtfCell cellSpacer = new RtfCell(new Phrase(nbs, new RtfFont("Arial", 9, RtfFont.NORMAL)));