Apply Bold Font to subset of a string and center align

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF Generator for .NET (v10.x)  /  Display Thread

DynamicPDF Generator for .NET (v10.x) Forum

Hi Team,

I am evaluating your product to use in one of our application. While evaluating I am facing difficulty for the below requirement.
I need the output in the below format with center align
<b>Field Heading:</b> Value

I have tried with FormattedTextArea page element. With this I am able to get "<b>Field Heading:</b> Value" but unable to do center align.

Can you please help me out to solve this problem of mine?


Thanks,
Chinmaya
Posted by a ceTe Software moderator
Hello Chinmaya,

Yes, you can center align the text in the FormattedTextArea by setting the Align property of the paragraph style and VAlign property of the FormattedTextArea. Below is the code sample.

            Document document = new Document();
            Page page = new Page();
            string text = "<b>Field Heading:</b>";
            FormattedTextArea fta = new FormattedTextArea(text, 0, 0, 100, 30, FontFamily.Helvetica, 14, true);
            fta.Style.Paragraph.Align = TextAlign.Center;
            fta.VAlign = VAlign.Center;
            page.Elements.Add(fta);
            document.Pages.Add(page);
            document.Draw(@"C:\Temp\TestFTA.pdf");

Thanks,
ceTe Software Support Team
It works like a champ. Thank you very much for the support.

All times are US Eastern Standard time. The time now is 11:55 AM.