It's not a good idea to use a String with dots when you need a dotted line. It's better to use a dotted line created using the DottedLineSeparator
class. See for instance the UnderlineWithDottedLine
example.
Paragraph p = new Paragraph("This line will be underlined with a dotted line.");
DottedLineSeparator dottedline = new DottedLineSeparator();
dottedline.setOffset(-2);
dottedline.setGap(2f);
p.add(dottedline);
document.add(p);
In this example (see underline_dotted.pdf for the result), I add the line 2 points under the baseline of the paragraph (using the setOffset()
method) and I define a gap of 2 points between the dots (using the setGap()
method).