Inconsistent default text highlight color

77 views
Skip to first unread message

Thorsten Hersam

unread,
Jun 18, 2018, 1:09:41 PM6/18/18
to PDFTron WebViewer
Hi,

When the document has loaded, I access the reader control's toolModeMap and "inject" red as the default StrokeColor for the AnnotationCreateTextHighlight ToolMode.

readerControl.toolModeMap['AnnotationCreateTextHighlight'].defaults.StrokeColor = { R: 255, G: 0, B: 0, A:1};

I have taken this approach from the function handleAnnotationCreate in AnnotationEdit.js (Line 1038).

I am using this approach in order to define the default text highlight color and I have found this to work with the Text Highlight Annotation Tool.
However when I select text with the Cursor Arrow and then click on "Highlight Text" in the opened context menu a different color will be used.

This is suprising as the same code is executed as with using the Text Highlight tool directly. During debug I find that 

annotTool.defaults.StrokeColor 

in

textAnnot.StrokeColor = annotTool.defaults.StrokeColor; (Line 1049 of AnnotationEdit.js)

actually returns my color preference but 

textAnnot.StrokeColor

somehow is not correctly setting the annotation's color.

Can you please check this issue?
Please let me know if there is a better way to setting the TextHighlight Annotations default color for ALL ways that allow adding a text hightlight. 
This (https://www.pdftron.com/documentation/web/guides/basics/annotations/customizing-tools) does not work for me as it only changes the color when using the TextHighlight Annotation Tool directly.
Also I do not want to have the same color always. I just would like to have a different default color.

Kind regards,

Thorsten

Matt Parizeau

unread,
Jun 19, 2018, 6:02:18 PM6/19/18
to PDFTron WebViewer
Hi Thorsten,

You should create an Annotations.Color object instead of passing in an object with the R, G, B and A properties.

readerControl.toolModeMap['AnnotationCreateTextHighlight'].defaults.StrokeColor = new Annotations.Color(255, 0, 0, 1);

When created from the tool the default stroke color is normalized into an Annotations.Color object but this isn't done in AnnotationEdit.js which is why it works in one place but not the other.

Matt Parizeau
Software Developer
PDFTron Systems Inc.

Thorsten Hersam

unread,
Jun 21, 2018, 2:09:13 PM6/21/18
to PDFTron WebViewer
Merci, this works perfectly fine :-)
Reply all
Reply to author
Forward
0 new messages