Get color from highlight

PDF-XChange Editor SDK for Developers

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, 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
EricAriens
User
Posts: 130
Joined: Tue May 03, 2016 1:11 pm

Get color from highlight

Post by EricAriens »

Hi,

I created some code to create a 'square highlight'.
This is the method to create the highlight:

Code: Select all

	    private void MakeSquareImageHighLight(IPXC_Annotation pxcAnnotation)
        {
            IPXV_CommentStylesManager stylesManager = pdfCtl.Inst.CommentStylesManager;
            ICabNode highLightStyle = stylesManager.GetCurrentStyle((int)Tools.HighLight);
            string color = highLightStyle[2].v.ToString();
            int nID = pdfCtl.Inst.Str2ID("op.annots.setProps", false);
            PDFXEdit.IOperation Op = pdfCtl.Inst.CreateOp(nID);
            PDFXEdit.ICabNode input = Op.Params.Root["Input"];
            input.Add().v = pxcAnnotation;
            PDFXEdit.ICabNode options = Op.Params.Root["Options"];
            options["FColor"].v = color;
            options["SColor"].v = color;
            options["BlendMode"].v = IXC_BlendMode.Blend_Multiply;
            options["Mask"].v = 0x00000008 | 0x00000010 | 0x00200000;
            Op.Do();
            _makeSquareImageHighLight = false;
        }
Tools is an enum with Tools.HighLite = 2017. This worked on the previous release (6.0.317).
I assumed the styles where constant. This is not the case :( :oops:
How can I get the current HighLightStyle so I can retrieve the color?

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

Re: Get color from highlight

Post by Sasha - Tracker Dev Team »

Hello Eric,

The command identifiers are constant, meaning the string representations of them, whilst the number values can change throughout the versions. In the FullDemo project, we recalculate the number values from the string identifiers when the project starts:

Code: Select all

private void InitIDS()
{
	nIDS = new int[(int)IDS._last_];
	for (IDS i = 0; i < IDS._last_; i++)
	{
		string sid = Enum.GetName(typeof(IDS), i);
		if (sid[0] == '_') // skip all like '_op_first_', '_op_last_', '_e_first_', etc..
		{
			nIDS[(int)i] = 0;
			continue;
		}
		sid = sid.Replace('_', '.');
		nIDS[(int)i] = pdfCtl.Inst.Str2ID(sid);
	}
}
You can do the same in your code and then you can use the enum number values for your code.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
EricAriens
User
Posts: 130
Joined: Tue May 03, 2016 1:11 pm

Re: Get color from highlight

Post by EricAriens »

Hi,

I already use that in my code so that should be no problem.
Can you give me the string representations of the tools?

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

Re: Get color from highlight

Post by Sasha - Tracker Dev Team »

Hello Eric,
You mean the Annotation types? If so, there should be a commented section in the FullDemo in the private void pdfCtl_OnEvent(object sender, AxPDFXEdit._IPXV_ControlEvents_OnEventEvent e) method. Search for example PrinterMark and you should find it easily.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
EricAriens
User
Posts: 130
Joined: Tue May 03, 2016 1:11 pm

Re: Get color from highlight

Post by EricAriens »

Hi,

I think you refer to this

Code: Select all

uint squareAnnotType = pxsInst.StrToAtom("Square");
uint annotsCnt = annotsEvent.Items.Count;
for (uint i = 0; i < annotsCnt; i++)
{
	PDFXEdit.IPXC_Annotation annot = annotsEvent.Items[i];
	if (squareAnnotType == annot.Type)
	{
		uint pageIndex = annot.Page.Number;
	}
}
/
But the annotation created is a rectangle.
How to find the highlight tool then?

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

Re: Get color from highlight

Post by Sasha - Tracker Dev Team »

Hello Eric,

Here's the list that I have:

Code: Select all

uint squareAnnotType = pxsInst.StrToAtom("Square");
// Other types:
//	Link,
//	Popup,
//	Movie,
//	Widget,
//	Screen,
//	PrinterMark,
//	TrapNet,
//	Watermark,
//	3D,
//	RichMedia,
//	Text,
//	FreeText,
//	Line,
//	Square,
//	Circle,
//	Polygon,
//	PolyLine,
//	Highlight,
//	Underline,
//	Squiggly,
//	StrikeOut,
//	Stamp,
//	Caret,
//	Ink,
//	FileAttachment,
//	Sound,
//	Redact,
//	Projection,
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
EricAriens
User
Posts: 130
Joined: Tue May 03, 2016 1:11 pm

Re: Get color from highlight

Post by EricAriens »

pxsInst.StrToAtom does not give the correct value.

The StrToAtom value for Highlight = 2915
The highLight style id = 2050

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

Re: Get color from highlight

Post by Sasha - Tracker Dev Team »

Ah, sorry, I though you wanted the Annotations' IDs =)
Here's the Tools list:

Code: Select all

tool.hand
tool.snapshot
tool.zoom
tool.loupe
tool.calibrate
tool.link
tool.media
tool.editAnnots
tool.editContent
tool.selectText
tool.annot.square
tool.annot.circle
tool.annot.stickyNote
tool.annot.fileAttachment
tool.annot.sound
tool.annot.line
tool.annot.arrow
tool.annot.distance
tool.annot.polyline
tool.annot.polygon
tool.annot.cloud
tool.annot.perimeter
tool.annot.area
tool.annot.textBox
tool.annot.callout
tool.annot.typeWriter
tool.annot.editLinks
tool.annot.redaction
tool.annot.pencil
tool.annot.eraser
tool.annot.stamp
tool.annot.highlight
tool.annot.underline
tool.annot.strikeout
tool.digitSign
tool.field
tool.editFields
tool.addText
tool.cropPage
tool.selBarcodePlace
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
EricAriens
User
Posts: 130
Joined: Tue May 03, 2016 1:11 pm

Re: Get color from highlight

Post by EricAriens »

Hi,

Nope not correct :(

pxsInst.StrToAtom("tool.annot.highlight") = 6897

Should be 2050

This are the tools I am talking about with the id in 3.17 and the id in 318
Square = 1996 = 2029
Oval = 1997 = 2030
StickyNote = 1998 = 2031
FileAttachment = 1999 = 2032
Sound = 2000 = 2033
Line = 2001 = 2034
Arrow = 2002 = 2035
Distance = 2003 = 2036
PolygonLine = 2004 = 2037
Polygon = 2005 = 2038
Cloud = 2006 = 2039
Perimeter = 2007 = 2040
Area = 2008 = 2041
TextBox = 2009 = 2042
CallOut = 2010 = 2043
Typewriter = 2011 = 2044
Pencil = 2014 = 2047
HighLight = 2017 = 2050
Underline = 2018 = 2051
Strikeout = 2019 = 2052


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

Re: Get color from highlight

Post by Sasha - Tracker Dev Team »

You need to use

Code: Select all

int nSquareTool = uiInst.Str2ID("tool.annot.square");
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
EricAriens
User
Posts: 130
Joined: Tue May 03, 2016 1:11 pm

Re: Get color from highlight

Post by EricAriens »

Hi,

That did the trick.

Thanks

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

Re: Get color from highlight

Post by Sasha - Tracker Dev Team »

Glad that helped :wink:
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply