Community

Set text as bold

 Hello,

I get tex block with one paragraph. How can I make this text bold?

I tried:

IParagraph paragraph = paragraphs.getElement(0);
ICharParams params = engine.CreateCharParams();
paragraph.GetCharParams(0, params);
params.setIsBold(true);
paragraph.SetCharParams(0, paragraph.getLength(), params, 0,1);

But this doesn't work.

Thank you.

Was this article helpful?

0 out of 0 found this helpful

Comments

1 comment

  • Avatar
    Permanently deleted user

    Hello,

    Most likely, in your code, you refer to an incorrect paragraph. You may set all text in your document bold using the code below. Please make sure that you run the code after you have performed the document synthesis.

     

            private void ApplyBold(FRDocument document)
            {
                FREngine.ICharParams bold = engineLoader.Engine.CreateCharParams();
                bold.IsBold = true;

                foreach (FREngine.FRPage page in document.Pages)
                {
                    foreach (FREngine.IBlock block in page.Layout.Blocks)
                    {
                        if (block.Type != BlockTypeEnum.BT_Text)
                        {
                            continue;
                        }
                        foreach (FREngine.IParagraph paragraph in block.GetAsTextBlock().Text.Paragraphs)
                        {
                            paragraph.SetCharParams(0, paragraph.Length, bold, 0 /*keep flags*/, (int)StyleParamsEnum.SF_Bold); 
                        }
                    }
                }
            }
    0

Please sign in to leave a comment.