I am attempting to convert a text file to a pdf using GemBox. I can get the text imported correctly but the font type and size aren't being applied and the sentence spacing seems to be doubled.
This is what I have so far:
public static void CreateDoc(string ebillpath)
{
using (var sr = new StreamReader(ebillpath))
{
var doc = new DocumentModel();
doc.DefaultCharacterFormat.Size = 10;
doc.DefaultCharacterFormat.FontName = "Courier New";
var section = new Section(doc);
doc.Sections.Add(section);
string line;
var clearedtop = false;
while ((line = sr.ReadLine()) != null)
{
if (string.IsNullOrEmpty(line) && !clearedtop)
{
continue;
}
clearedtop = true;
Paragraph paragraph2 = new Paragraph(doc, new Run(doc, line));
section.Blocks.Add(paragraph2);
}
PageSetup pageSetup = new PageSetup(); // section.PageSetup;
var pm = new PageMargins();
pm.Bottom = 36;
pm.Top = 36;
pm.Right = 36;
pm.Left = 36;
pageSetup.PageMargins = pm;
doc.Save(@"d:\temp\test.pdf");
}
}
This text file uses spaces to format the text correctly so I need to set the font to Courier New.
This is an example of what the text file looks like with correct formatting:
And this is what it comes out to look like in pdf form:
Each line seems to be doubled and the font isn't being applied.
Any suggestions?

