コミュニティ

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.

この記事は役に立ちましたか?

0人中0人がこの記事が役に立ったと言っています

コメント

1件のコメント

  • 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

サインインしてコメントを残してください。