New lines are not added to a Cell on a Table

Hi i am trying to fill a Table and some cells contain text with new line \n, but this new line is not shown on the Table. We write more complicated code, but even this simple example doesn’t add a new line.

@Test
public void testTableCellsWithLine() throws Exception {
	Document document = new Document();
	DocumentBuilder builder = new DocumentBuilder(document);

	builder.startTable();
	builder.insertCell();
	builder.endRow();
	builder.endTable();


	Table table = (Table) document.getChild(NodeType.TABLE, 0, true);
	Cell cell = table.getFirstRow().getFirstCell();
	cell.getCellFormat().setFitText(false);

	// If true, wrap text for the cell.
	cell.getCellFormat().setWrapText(true);

	Paragraph paragraph = new Paragraph(document);
	Run run = new Run(document, "i want a \n new line");
	paragraph.appendChild(run);
	cell.appendChild(paragraph);


        document.save("C:\\Documents\\BDC_General\\TableWithLine.docx");
}

The same problem applies with that kind of code:

cell.getParagraphs()
    .get(0)
    .getRuns()
    .get(0)
    .setText("I want \n a new line");

I attach the word document to see that there is no new line there. TableWithLine.docx (17.4 KB)

Thank you,
Eleftheria

@Eleftheria_Stefanou IF you should like to insert a soft line break (Shift+Enter), you can use "\v":

Run run = new Run(document, "i want a \v new line");

if you would like a paragraph break, the you should code code like this:

Paragraph paragraph1 = new Paragraph(document);
paragraph1.appendChild(new Run(document, "i want a"));
Paragraph paragraph2 = new Paragraph(document);
paragraph2.appendChild(new Run(document, "new line"));
        
cell.appendChild(paragraph1);
cell.appendChild(paragraph2);