How to set the color of the HighlightText Tool

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

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

Post Reply
reinierkops
User
Posts: 93
Joined: Mon Jul 07, 2008 8:41 am

How to set the color of the HighlightText Tool

Post by reinierkops »

Is there a possibility to set the color of the Highlight tool via code. I need to create 4 different buttons, I preffer in the toolbar of the control, with 4 different colors.
User avatar
John - Tracker Supp
Site Admin
Posts: 5219
Joined: Tue Jun 29, 2004 10:34 am
Location: United Kingdom
Contact:

Re: How to set the color of the HighlightText Tool

Post by John - Tracker Supp »

Hi,

It is possible - but is undocumented.

:
0. Select needed text-fragment in the document:
1. SetProperty("Annots.Defaults.<HighlightType>.SColor", RGB(255,0,0), 0);
<HighlightType>=HightLight | Underline | StrikeOut | Replace;
2. Run command:
DoVerb(NULL, "ExecuteCommand", "<CommandName>", NULL, 0);
<CommandName> = HighlightSelText | UnderlineSelText | CrossOutSelText | ReplaceSelText

Hope that helps
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com
reinierkops
User
Posts: 93
Joined: Mon Jul 07, 2008 8:41 am

Re: How to set the color of the HighlightText Tool

Post by reinierkops »

I have problems with the RGB(255,0,0) value.

I tried to convert a Color.ToARGB, but that won't work. What do I need to do?

private void SetHighlightColor(Color mColor)
{
axCoPDFXCview1.SetProperty("Annots.Defaults.Highlight.SColor", (mColor.R,mColor.G,mColor.B), 0);
object vDataOut;
axCoPDFXCview1.DoVerb(null,"ExecuteCommand","HightlightSelText",out vDataOut,0);
}
User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 2352
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: How to set the color of the HighlightText Tool

Post by Vasyl-Tracker Dev Team »

The correct example:

Color Clr = Color.FromArgb(0, 0, 255); // blue
try
{
axCoPDFXCview1.SetProperty("Annots.Defaults.Hightlight.SColor", System.Drawing.ColorTranslator.ToWin32(Clr), 0);
object vDataOut;
axCoPDFXCview1.DoVerb(null, "ExecuteCommand", "HighlightSelText", out vDataOut, 0);
}
catch (Exception ex)
{
//..
}

NOTE: the selected 't' character in 'Hightlight' fragment of the property name will be removed in the future (in next build) - it is our mistake, should be 'Highlight'.
You should check it before use for next build.
Vasyl Yaremyn
Tracker Software Products
Project Developer

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
reinierkops
User
Posts: 93
Joined: Mon Jul 07, 2008 8:41 am

Re: How to set the color of the HighlightText Tool

Post by reinierkops »

It works great!!!
reinierkops
User
Posts: 93
Joined: Mon Jul 07, 2008 8:41 am

Re: How to set the color of the HighlightText Tool

Post by reinierkops »

Hey guys,

Is there an extensive reference for the stuff we can do with the SetProperty command on the activeX control?
Need to set the color of the pencil tool, but can't find which verb to use.

Checked the documentation that came with the SDK, but that did not list it.

cheers
User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 2352
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: How to set the color of the HighlightText Tool

Post by Vasyl-Tracker Dev Team »

This possibility (changing color of the pencil tool), and others, will be added in the nearest future.
Vasyl Yaremyn
Tracker Software Products
Project Developer

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
reinierkops
User
Posts: 93
Joined: Mon Jul 07, 2008 8:41 am

Re: How to set the color of the HighlightText Tool

Post by reinierkops »

ok, thanks.
ugradedeveloper
User
Posts: 223
Joined: Wed Aug 22, 2007 4:40 pm

Re: How to set the color of the HighlightText Tool

Post by ugradedeveloper »

Vasyl-Tracker Dev Team wrote:This possibility (changing color of the pencil tool), and others, will be added in the nearest future.
I have a couple of questions about this.

1) Can this be used to set the default properties for annotations, or only to modify existing text/annotations?

2) Have any more of these been added, and is it the plan that they will remain undocumented, or will they be added to the documentation in the future?

Thanks.
User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 2352
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: How to set the color of the HighlightText Tool

Post by Vasyl-Tracker Dev Team »

1) Can this be used to set the default properties for annotations, or only to modify existing text/annotations?
In nearest future you will be able to edit default properties of annots, like as:
// edit/get specified style for line-annot:
SetProperty("Commenting.Line.Styles[0].SColor", "yellow", 0);
SetProperty("Commenting.Line.Styles[0].Opacity", 0.75, 0);
// get ID of this line-style
GetProperty("Commenting.Line.Styles[0].ID", LineStyleID, 0);
// select this style to line-tool:
SetProperty("Tool.Line.Style", LineStyleID, 0);
-and more others.
Also you will be able to edit existing annots, like as:
SetProperty("Documents[0].Pages[0].Annots[2].SColor", "red", 0);
SetProperty("Documents[0].Pages[0].Annots[2].Opacity", 0.75, 0);
// get annot type:
GetProperty("Documents[0].Pages[0].Annots[2].Type", AnnotType, 0);
// after call AnnotType="Line", for example
2) Have any more of these been added, and is it the plan that they will remain undocumented, or will they be added to the documentation in the future?
These features are still undocumented because we still working on it. We will update documentation when we finish work on it.
Also earlier code you should change to:
Color Clr = Color.FromArgb(0, 0, 255); // blue
try
{
axCoPDFXCview1.SetProperty("Commenting.Highlight.Styles[0].SColor", System.Drawing.ColorTranslator.ToWin32(Clr), 0);
object vDataOut;
axCoPDFXCview1.DoVerb(null, "ExecuteCommand", "HighlightSelText", out vDataOut, 0);
}
catch (Exception ex)
{
//..
}
Note: this code will work properly if "Commenting.Highlight.Styles[0].ID" == "Tools.Highlight.Style"
For simplify, you can use new method for highlight selected text - look to AX help, "Objects::Documents::<Item>.HighlightSelection" section.
Vasyl Yaremyn
Tracker Software Products
Project Developer

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Post Reply