.NET/C# Dealing with Whitespaces
I had an issue where MigraDoc/PDFsharp stripped all whitespaces from a textfile I was converting to PDF. This was solved by replacing whitespaces with a non-breaking space.
Code Sample
string[] TXTfile = File.ReadAllLines(TXTFileLocation, Encoding.GetEncoding(1252));
foreach (string l in TXTfile) {
paragraph.AddFormattedText(l.Replace(" ", "\u00A0"));
}