This is a migrated thread and some comments may be shown as answers.

Cannot create a colored text background in a PDF

3 Answers 362 Views
PdfProcessing
This is a migrated thread and some comments may be shown as answers.
Roland
Top achievements
Rank 3
Iron
Iron
Veteran
Roland asked on 02 Nov 2020, 11:12 PM
block.GraphicProperties.IsFilled = true;
 block.GraphicProperties.FillColor = color;

 

does not seem to do anything.

 

block.BackgroundColor = color;

 

only colors the line, not the entire rectangle of the block.

 

 

3 Answers, 1 is accepted

Sort by
0
Roland
Top achievements
Rank 3
Iron
Iron
Veteran
answered on 02 Nov 2020, 11:38 PM

I resolved it by useing the editor instead:

    public static void DrawRect(this FixedContentEditor editor, Size size, ColorBase color)
    {
      editor.SaveGraphicProperties();
      editor.GraphicProperties.IsFilled = true;
      editor.GraphicProperties.FillColor = color;
      editor.GraphicProperties.IsStroked = false;
      editor.DrawRectangle(new Rect(0, 0, size.Width, size.Height));
      editor.RestoreGraphicProperties();
    }

0
Dimitar
Telerik team
answered on 04 Nov 2020, 12:09 PM

Hi Roland,

You can use TextProperties.HighlightColor as well. Here is an example: 

Block block = new Block();
block.TextProperties.HighlightColor = new RgbColor(255, 0, 0);         
block.InsertText("Test");

I hope this helps. Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Roland
Top achievements
Rank 3
Iron
Iron
Veteran
answered on 21 Nov 2020, 01:31 PM
block.TextProperties.HighlightColor does work indeed
Tags
PdfProcessing
Asked by
Roland
Top achievements
Rank 3
Iron
Iron
Veteran
Answers by
Roland
Top achievements
Rank 3
Iron
Iron
Veteran
Dimitar
Telerik team
Share this question
or