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, Sean - Tracker, Chris - Tracker Supp, 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 » Wed Jan 13, 2021 4:50 pm

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 » Wed Jan 13, 2021 5:48 pm

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 » Wed Jan 13, 2021 5:50 pm

(color.G << 8)

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

Re: Text Box Opacity

Post by Sasha - Tracker Dev Team » Thu Jan 14, 2021 10:21 am

Hello AlexD,

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

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
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 » Thu Jan 14, 2021 2:05 pm

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.

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

Re: Text Box Opacity

Post by Sasha - Tracker Dev Team » Thu Jan 14, 2021 2:34 pm

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
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
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 » Thu Jan 14, 2021 5:21 pm

...so it is ignoring 'Alpha'. Thanks

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

Re: Text Box Opacity

Post by Sasha - Tracker Dev Team » Fri Jan 15, 2021 2:04 pm

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
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
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 » Sun Jan 17, 2021 4:16 pm

Thanks

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

Text Box Opacity

Post by Sasha - Tracker Dev Team » Mon Jan 18, 2021 11:01 am

:)
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

Post Reply