I have a problem printing a watermark on my pdf files. Normal text is working great, but as soon as a newline is included, the text after the newline simply disappears.
The text is coming from an textarea field in our WebApplication, and if I directly use the String with the \n included, the text after the newline disappears. In suggestions on stackoverflow I found a solution by using "Chunk.NEWLINE" but it changes nothing and the text still is gone.
// Phrase p = new Phrase(watermarkText, f);
String[] parts = watermarkText.split("\\n");
Paragraph para = new Paragraph();
for (int k = 0; k < parts.length; k++) {
Phrase p = new Phrase("", f);
p.add(parts[k]);
p.add(Chunk.NEWLINE);
para.add(p);
}
PdfGState gs1 = new PdfGState();
gs1.setFillOpacity(opacity);
over.setGState(gs1);
ColumnText.showTextAligned(over, Element.ALIGN_CENTER, para, x_position, y_position, rotation);
The splitting works great, I have exactly the 2 parts I wanted, but Chunk.NEWLINE changes nothing.
I'm using iText 5.5.0, I tried upgrading to 5.5.10 but that behaviour is still the same. If there are any known bugs, I haven't found them and if I am doing something wrong I simply don't see it.
I hope there is somebody out there who can help me.