I am passing a string with \n (like “Hello\nWorld”) to a method that sets the Rich text control in Java but the string is displayed all in one line…any trick here?
public static void updateRichText(Document doc, StructuredDocumentTag sdt, String txtVal) {
Run run = new Run(doc);
run.setText(txtVal);
if (sdt.getLevel() == MarkupLevel.INLINE) {
sdt.removeAllChildren();
sdt.getChildNodes().add(run);
} else if (sdt.getLevel() == MarkupLevel.BLOCK) {
sdt.removeAllChildren();
Paragraph para = (Paragraph) sdt.appendChild(new Paragraph(doc));
para.getRuns().add(run);
sdt.getChildNodes().add(para);
} else if (sdt.getLevel() == MarkupLevel.CELL) {
if (sdt.getFirstChild().getNodeType() == NodeType.CELL) {
Cell cell = (Cell) sdt.getFirstChild();
cell.removeAllChildren();
cell.ensureMinimum();
Paragraph para = ((Cell) sdt.getFirstChild()).getFirstParagraph();
para.getRuns().add(run);
}
}
}