Text Box Opacity

A forum for questions or concerns related to the PDF-XChange Core API SDK

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
AlexD
User
Posts: 7
Joined: Wed Jan 13, 2021 4:20 pm

Text Box Opacity

Post by AlexD »

Hello,

• What is the way to set Opacity for a Text Box field?
I tried to get the Text Box IPXC_Annotation widget and then set Opacity value on Annotation Data, but it does not work.
• Is there a way to make a Text Box' text transparent? Annotation Data has FColor and SColor properties of IColor type, but the interface does not have any opacity settings.

Any code snippets in C# will be appreciated.

Thank you
AlexD
User
Posts: 7
Joined: Wed Jan 13, 2021 4:20 pm

Re: Text Box Opacity

Post by AlexD »

There is another option to add text using IPXC_ContentCreator which allows to set opacity, but there is something strange with color displayed.

SetFillColorRGB accepts parameter of uint type.
The following is standard conversion from html color to uint:
Color color = System.Drawing.ColorTranslator.FromHtml("#FF0000");
uint uintColor = (uint)((color.A << 24) | (color.R << 16) |
(color.G << 8) | (color.B << 0));
So CC.SetFillColorRGB(uintColor), where CC is IPXC_ContentCreator instance, should produce red fill color, but it the color is blue.

Any ideas?
AlexD
User
Posts: 7
Joined: Wed Jan 13, 2021 4:20 pm

Re: Text Box Opacity

Post by AlexD »

(color.G << 8)
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Text Box Opacity

Post by Sasha - Tracker Dev Team »

Hello AlexD,

Check out the CoreAPIDemo project - it holds many samples:
https://github.com/tracker-software/PDF ... oreAPIDemo

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
AlexD
User
Posts: 7
Joined: Wed Jan 13, 2021 4:20 pm

Re: Text Box Opacity

Post by AlexD »

The CoreApi project does not work with the following code modification

Convert from html color to uint:
Color color = System.Drawing.ColorTranslator.FromHtml("#FF0000");

Get uint color value:
uint uintColor = (uint)((color.A << 24) | (color.R << 16) |
(color.G << 8) | (color.B << 0));



CC.SetFillColorRGB(uintColor), where CC is IPXC_ContentCreator instance, should produce red fill color, but it the color is blue.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Text Box Opacity

Post by Sasha - Tracker Dev Team »

Hello AlexD,

That's because the construction of color looks like this:

Code: Select all

#define RGB(r,g,b)          ((COLORREF)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16)))
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
AlexD
User
Posts: 7
Joined: Wed Jan 13, 2021 4:20 pm

Re: Text Box Opacity

Post by AlexD »

...so it is ignoring 'Alpha'. Thanks
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Text Box Opacity

Post by Sasha - Tracker Dev Team »

Hello AlexD,

Not only that - you have specified color components in reverse. You can use the SetFillAlpha method to specify the Alpha value if needed.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
AlexD
User
Posts: 7
Joined: Wed Jan 13, 2021 4:20 pm

Re: Text Box Opacity

Post by AlexD »

Thanks
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Text Box Opacity

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply