Posted by a ceTe Software moderator
Hello,
Thanks for sending the requested information to our support team. We did some testing on our end and found that when the text having space at the start of the string is moved to next line then the space is ignored. This is desired behavior with our DynamicPDF Generator for .NET API.
You can achieve your requirement by adding each character of the string individually using TextArea page element and setting the correct Y position to it. Below is the sample code for it.
Document document = new Document();
Page page = new Page();
document.Pages.Add(page);
string text = "District of Columbia";
float y = 100;
foreach (char ch in text.ToCharArray())
{
TextArea area = new TextArea(ch.ToString(), 100, y, 10, 20);
Font font = Font.Courier;
float widht = font.GetTextWidth(ch.ToString(), 9);
area.Width = widht;
area.Font = font;
area.FontSize = 9;
area.Height = area.GetRequiredHeight();
area.VAlign = VAlign.Center;
area.Align = TextAlign.Center;
page.Elements.Add(area);
y = area.Y + area.Height;
}
document.Draw(@"C:\MyDocument.pdf");
Thanks,
ceTe Software Support Team.