Try to store \n
or \r\n
instead of \\n
.
How does New line works in MongoDB with C# .NET?
Lakshmanan Balasubramanian
101
Reputation points
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
Accepted answer
-
Viorel 122.2K Reputation points
2025-06-19T09:19:33.94+00:00