Page 1 of 1

Can a textblock have a color background?

Posted: Tue Jul 24, 2018 7:41 pm
by whoit
I'm using ContentCreator, and ShowTextBlock.

Is it possible to set the background of the textblock color ?

For example, if I create a textblock with the intent of covering existing text, I would want the text to be black, and the background to be white...
Or if want, white text on a black background, etc..

Thanks.

Re: Can a textblock have a color background?

Posted: Wed Jul 25, 2018 8:57 am
by Sasha - Tracker Dev Team
Hello Wayne,

You should fill the rectangle first and then draw the text on top. The rectangle can be calculated when you output the text itself with DTF_CalcSizeOnly flag.
For more, please refer to the https://github.com/tracker-software/PDF ... oreAPIDemo project.
Look into the 4.3 Text Rendering Mode and 4.7 Patterns sample for more info.

Cheers,
Alex

Re: Can a textblock have a color background?

Posted: Wed Jul 25, 2018 1:43 pm
by whoit
OK, thanks - I'll dig around.

BTW I've downloaded and run the new Demo - nice!

Only one issue: While running, after I select any sample from the left side, the "Go To Source" button does nothing,
nor does the code show in the window below the button.

(I'm running VS 2017)

Re: Can a textblock have a color background?

Posted: Wed Jul 25, 2018 1:48 pm
by Sasha - Tracker Dev Team
Hello Wayne,

Please check the NuGet packages for the project - the FCTB package should be installed for the text coloring (just for a test to ensure that they did).
As for the problem, please check the toolStripButton2_Click implementation - and read the exception codes if they occur.
I think you can experience the problem here:

Code: Select all

EnvDTE.DTE dte = (EnvDTE.DTE)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE");
Cheers,
Alex