How does New line works in MongoDB with C# .NET?

Lakshmanan Balasubramanian 101 Reputation points
2025-06-19T08:40:59.06+00:00

I have a collection and within the collection I have a data stored something like this.

{ 
"_id": { "$oid": "01010101010101010" }, 
"heading": 
	{ 
		"desc": "Hello I am Vinicius. \\n I play for Real Madrid"
	} 
}

I am using QuestPDF which prints the data from the Database and generates a pdf.

In my C# code I have something like this:

page.Content().Table(table =>
{
    table.ColumnsDefinition(column =>
    {
        column.RelativeColumn();
    });
	table.Cell().Column(1).Row(1).Text(dbFootbalCol.heading.desc);
});

The output I am expecting is:

Hello I am Vinicius. 
I play for Real Madrid

And What I see is:

Hello I am Vinicius. \n I play for Real Madrid

What I am doing wrong? Is C# ignoring the new line character?

Thanks in Advance.

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,553 questions
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 122.2K Reputation points
    2025-06-19T09:19:33.94+00:00

    Try to store \n or \r\n instead of \\n.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.