Changing the default color of tools in the annotation tool bar

Product: PDFTron UWP

Product Version: 9.4

I would like to change the default color that a tool in the Annotation toolbar is set to. It is currently red upon starting up and we would like it to be blue by default.

How can I go about achieving this? I did not find any docs on how to do this on UWP.

Hi saad.sharif,

Welcome to the PDFTron community!

The color in the tool in the Annotation toolbar is red because the tool’s current color is red. If you change the color used by the tool, the color will also change if that makes sense.

The property for that color is the ViewerControl.AnnotationToolbar.ViewModel.CurrentToolColor where CurrentToolColor is the selected tool’s current color.

Where I initialise the annotation toolbar, remove unnecessary tools, I am doing
AnnotationToolbar.ViewModel.CurrentToolColor = new SolidColorBrush(new Windows.UI.Color() { A = 0, R = 0, B = 250, G = 0 });

But when I go into the App it is not changing the tool colour, it is still red.

In the debugger, I see after setting and going and drawing, the colour I set has gone.

Most likely the color is being overwritten on initialization. The color is saved to local cache and retrieved on initialization. Perhaps overwriting the color after initialization is what you need to do or overwriting the saved settings.

Changing AnnotationToolbar.ViewModel.CurrentToolColor is not changing the colour of the annotations.

In our app we use a tablet device with a stylus. Even without using the annotation toolbar we can use this stylus to annotate using a pen. But this colour of the annotation is red, and we want it to be blue out of the box.

I have set the colour to be blue on the event OnRenderFinished, this property value is blue, as I have checked by setting breakpoints. But the annotation colour will be red, unless changed in the annotation toolbar.

Have you tried checking if the value of Settings.GetAnnotationColor is what you are looking for? This value will overwrite the CurrentToolColor as the Tool is selected.

I believe the issue is that the current tool is always selected as pan, and the ViewModel.CurrentTool appears to be a read only property, so thus on initialising the PDF I cannot change the colour of the pen, so that on start-up of PDFTron, without touching the toolbar, a stylus will write in blue ink.

A way I could do that is by setting the pen tool colour, either by setting it directly or perhaps setting the current tool to the pen to then set the current tool colour.

However, I do not see a way to do either in PDFTron UWP.

Alright, I will look into this some more.

At a later date, a method will be added for setting the annotation color in local Settings.