Change annotation colors tool
Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Paul - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange
-
- User
- Posts: 1372
- Joined: Mon Nov 15, 2021 8:38 pm
Re: Change annotation colors tool
Have you by any change made a tool that changes the font of all selected objects in a similar way? I can't tell what the best way to do that would be .
edit:
by the way does the script only change the stroke color, of for example rectangles? Is it possible to make it only change the stroke/fill color of the selected comments individually?
edit:
by the way does the script only change the stroke color, of for example rectangles? Is it possible to make it only change the stroke/fill color of the selected comments individually?
My wishlist https://forum.pdf-xchange.com/viewtopic.php?p=187394#p187394
Disable SPACE page navigation, fix kb shortcut for highlighting advanced search tool search field, bookmarks with numbers, toolbar small icon size, AltGr/Ctrl+Alt keyboard issues
Disable SPACE page navigation, fix kb shortcut for highlighting advanced search tool search field, bookmarks with numbers, toolbar small icon size, AltGr/Ctrl+Alt keyboard issues
-
- Site Admin
- Posts: 11036
- Joined: Wed Jan 03, 2018 6:52 pm
Re: Change annotation colors tool
Hello, MedBooster
I am not sure about the logistics of making that work for the text inside of comments, but I believe it should be possible. I have mentioned it in another thread recently, but we do have an open ticket on that particular topic.
RT#4577: FR: Edit text format of multiple comments
As JS does not have access to Base content modification, it will not be possible able to modify base content text items, but as you can already do this from the properties pane for base content text, I assume that was not the desire.
Kind regards,
I am not sure about the logistics of making that work for the text inside of comments, but I believe it should be possible. I have mentioned it in another thread recently, but we do have an open ticket on that particular topic.
RT#4577: FR: Edit text format of multiple comments
As JS does not have access to Base content modification, it will not be possible able to modify base content text items, but as you can already do this from the properties pane for base content text, I assume that was not the desire.
Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD
+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
PDF-XChange Co. LTD
+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
-
- User
- Posts: 573
- Joined: Thu Jun 19, 2014 7:30 pm
Re: Change annotation colors tool
I've not made a tool like that - although it's definitely possible. I've just not run into a need myself so I didn't spend the time to do it.MedBooster wrote: ↑Mon Apr 15, 2024 3:41 pm Have you by any change made a tool that changes the font of all selected objects in a similar way? I can't tell what the best way to do that would be .
I think I talked about the idea in another post: I think a more generic tool that has more of a "filter" section that determines which annotations are changed based on characteristics (ie color, fill, text color, font, etc) and then a change section that decides that element is changed (ie border/fill/font/etc).
This tool filters by color: So it changes all elements of that color, whether they are outlines, fills or text.
I originally made this tool because when I do markups I send them in one color, and then change to another color once they are picked up. So I'd change all elements that were, say, red, to blue.
Last edited by Mathew on Mon Apr 15, 2024 8:24 pm, edited 1 time in total.
-
- User
- Posts: 573
- Joined: Thu Jun 19, 2014 7:30 pm
Re: Change annotation colors tool
By the way, it should not be too difficult to change this tool to work on fonts.
Or you could make something much simpler if you know the font and just run a script... something like (may have bugs):

Code: Select all
// Simple script to change fonts in annotations
{
//If you only want to change a single font, enter it here, otherwise leave blank to change all
const oldFont = '';
const anns = this.selectedAnnots;
const fontNames = [];
for (let ann of anns) {
// need to search richContents if it exists
// get fonts from richContents
if ( ann.richContents && ann.richContents.length ) {
for (let span of ann.richContents) {
// add it to the list if not there already
let fontList = span.fontFamily.length > 1 ? span.fontFamily : span.fontFamily[0].split(',') ;
fontList = fontList.filter( f => !fontNames.includes(f));
fontNames.push( ...fontList );
}
} else if ( ann.textFont ) {
// no rich contents
fontNames.push(ann.textFont);
}
}
let cTxt = fontNames.length + ' fonts found in selected annots:\n' + fontNames.join('\n');
if (oldFont) cTxt += '\n\nOnly changing font ' + oldFont;
console.println(cTxt);
// build object for app.response
cTxt = { cQuestion: cTxt,
cTitle: "Change fonts",
cDefault: fontNames[0],
cLabel: 'New font:',
};
let newFont = app.response( cTxt );
if (null != newFont) {
// change the fonts
for (let ann of anns) {
// need to change richContents if it exists
let revs = {};
// get fonts from richContents
if ( ann.richContents && ann.richContents.length ) {
let spans = [];
let changed = false;
for (let span of ann.richContents) {
// add it to the list of spans
spans.push(span);
if ( newFont != span.fontFamily[0] && ( !oldFont || oldFont == span.fontFamily[0] )) {
spans[spans.length-1].fontFamily = newFont.includes(',') ? newFont.split(',') : [newFont];
changed = true;
}
}
if (changed) {
ann.setProps({'richContents': spans});
}
} else if ( ann.textFont && newFont != ann.textFont && ( !oldFont || oldFont == ann.textFont )) {
// no rich contents
ann.textFont = newFont;
}
}
}
}
-
- Site Admin
- Posts: 11036
- Joined: Wed Jan 03, 2018 6:52 pm
Re: Change annotation colors tool

Dan McIntyre - Support Technician
PDF-XChange Co. LTD
+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
PDF-XChange Co. LTD
+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
-
- User
- Posts: 1372
- Joined: Mon Nov 15, 2021 8:38 pm
Re: Change annotation colors tool
We do have a "convert colors" tool, but I don't think that's it. What we are requesting is a "replace colors" tool – similar to the "replace font" tool.Mathew wrote: ↑Tue Mar 12, 2024 10:34 pm oh, and I agree: If this were a built-in tool, it would have access to the color picker, and be able to show a color square on the dialog box. As far as I know, there's no way to put images or colors on the dialog boxes that we can generate with javascript.
Here's my wish: That this tool were built-in and could also work on the content of the document, not just the annotations.
You do not have the required permissions to view the files attached to this post.
My wishlist https://forum.pdf-xchange.com/viewtopic.php?p=187394#p187394
Disable SPACE page navigation, fix kb shortcut for highlighting advanced search tool search field, bookmarks with numbers, toolbar small icon size, AltGr/Ctrl+Alt keyboard issues
Disable SPACE page navigation, fix kb shortcut for highlighting advanced search tool search field, bookmarks with numbers, toolbar small icon size, AltGr/Ctrl+Alt keyboard issues
-
- Site Admin
- Posts: 11036
- Joined: Wed Jan 03, 2018 6:52 pm
Re: Change annotation colors tool
Hello, MedBooster
Spreading the good news, the replace fonts tool, (which handles font color as well) is being updated in 386 to include this handling for comments as well
Kind regards,
Spreading the good news, the replace fonts tool, (which handles font color as well) is being updated in 386 to include this handling for comments as well

You do not have the required permissions to view the files attached to this post.
Dan McIntyre - Support Technician
PDF-XChange Co. LTD
+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
PDF-XChange Co. LTD
+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
-
- Site Admin
- Posts: 11036
- Joined: Wed Jan 03, 2018 6:52 pm
Re: Change annotation colors tool

Dan McIntyre - Support Technician
PDF-XChange Co. LTD
+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
PDF-XChange Co. LTD
+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
-
- User
- Posts: 573
- Joined: Thu Jun 19, 2014 7:30 pm
Re: Change annotation colors tool
I updated the tool in the post above to have the option to switch between decimal and hex notation, as well as edit the saved color names. I also made the icon 40x40 so it looks a bit better on the ribbon UI.
Let me know if you see something I messed up.You do not have the required permissions to view the files attached to this post.
-
- Site Admin
- Posts: 19868
- Joined: Mon Jan 12, 2009 8:07 am
Re: Change annotation colors tool
Hello Mathew,
Once again - many thanks for the lovely tools you are creating and maintaining!
Kind regards,
Stefan
Once again - many thanks for the lovely tools you are creating and maintaining!
Kind regards,
Stefan
-
- User
- Posts: 1372
- Joined: Mon Nov 15, 2021 8:38 pm
Re: Change annotation colors tool
Wow, version 1.4 is really something
I'm really liking the new edit color name function – is it correct that you can save colors in both HeX and RGB?
Will it get overwritten if you save it with different names 2 times? I tried and it seems it doesn't update right away.
btw... is there still no way to activate these JavaScript menus with keyboard shortcuts?
I'm really liking the new edit color name function – is it correct that you can save colors in both HeX and RGB?
Will it get overwritten if you save it with different names 2 times? I tried and it seems it doesn't update right away.
btw... is there still no way to activate these JavaScript menus with keyboard shortcuts?
You do not have the required permissions to view the files attached to this post.
My wishlist https://forum.pdf-xchange.com/viewtopic.php?p=187394#p187394
Disable SPACE page navigation, fix kb shortcut for highlighting advanced search tool search field, bookmarks with numbers, toolbar small icon size, AltGr/Ctrl+Alt keyboard issues
Disable SPACE page navigation, fix kb shortcut for highlighting advanced search tool search field, bookmarks with numbers, toolbar small icon size, AltGr/Ctrl+Alt keyboard issues
-
- User
- Posts: 573
- Joined: Thu Jun 19, 2014 7:30 pm
Re: Change annotation colors tool
Watch out for the hex numbering: Don't put a # in front of it - that'll confuse the script - I didn't think to check for that and omit it. It just assumes a series of hexadecimal numbers.
The decimal is just another representation of the same information. If you name a color while in decimal mode, then switch to hex, the name will stick. If you've not named the color before, it applies a default name using whatever the color representation was at that time (hex or dec) - but you can change it to whatever you want "Fav color", "Hates it", etc. If you prefer "Red" to be FF1100 then you can make another color called "Red" with that and it will override the default name - but like I said, it can get confusing
It should update the dialog right away except the left column "current color" - I realized that after I uploaded it and haven't had time to fix.
The decimal is just another representation of the same information. If you name a color while in decimal mode, then switch to hex, the name will stick. If you've not named the color before, it applies a default name using whatever the color representation was at that time (hex or dec) - but you can change it to whatever you want "Fav color", "Hates it", etc. If you prefer "Red" to be FF1100 then you can make another color called "Red" with that and it will override the default name - but like I said, it can get confusing

It should update the dialog right away except the left column "current color" - I realized that after I uploaded it and haven't had time to fix.
-
- User
- Posts: 1372
- Joined: Mon Nov 15, 2021 8:38 pm
Re: Change annotation colors tool
Thank you.
Btw. I don't think you responded to my question of whether it would be possible to display the "current color"-color in the text of the color code itself (in RGB or HeX)
also... I assume there is a reason for this, but maybe in the future when you have time you could make the current color column also which to HeX (as of now only "enter color" changes to HeX)
PS. when you open the dialogue, decimal is the default (pre-chosen), is there a way to change this to Hexadecimal? So that the other option is toggled first?
Btw. I don't think you responded to my question of whether it would be possible to display the "current color"-color in the text of the color code itself (in RGB or HeX)
also... I assume there is a reason for this, but maybe in the future when you have time you could make the current color column also which to HeX (as of now only "enter color" changes to HeX)
PS. when you open the dialogue, decimal is the default (pre-chosen), is there a way to change this to Hexadecimal? So that the other option is toggled first?
My wishlist https://forum.pdf-xchange.com/viewtopic.php?p=187394#p187394
Disable SPACE page navigation, fix kb shortcut for highlighting advanced search tool search field, bookmarks with numbers, toolbar small icon size, AltGr/Ctrl+Alt keyboard issues
Disable SPACE page navigation, fix kb shortcut for highlighting advanced search tool search field, bookmarks with numbers, toolbar small icon size, AltGr/Ctrl+Alt keyboard issues
-
- User
- Posts: 573
- Joined: Thu Jun 19, 2014 7:30 pm
Re: Change annotation colors tool
OK, thank you: There were a few bugs there that needed squashing. Hopefully done here.
I suspect it would be less work and more likely for Tracker to implement a builtin version of a change dialog than to implement changes to app.execDialog() though. Currently, the only workaround I can think of would be creating some type of annotation object that has the colors in it, or temporarily overlaying a form, but that's a lot of work.
Updated the current color column also: That column shows the saved name, so if you enter a custom color but don't save a name, it saves one based on whether you're in hex or dec at that time - maybe it would've been more intuitive if I'd just used "Custom color X" as default color name. I have updated the script to change that column if you go edit the custom color names though now.
The first time you load the tool, it will be decimal - but it should save your last setting between sessions. Is it not?
Unfortunately I don't know a way to show a color or image in the custom dialog boxes available to JS in PXE. Would be a really nice option, thoughMedBooster wrote: ↑Tue Apr 23, 2024 2:24 pm Btw. I don't think you responded to my question of whether it would be possible to display the "current color"-color in the text of the color code itself (in RGB or HeX)
also... I assume there is a reason for this, but maybe in the future when you have time you could make the current color column also which to HeX (as of now only "enter color" changes to HeX)
PS. when you open the dialogue, decimal is the default (pre-chosen), is there a way to change this to Hexadecimal? So that the other option is toggled first?

Updated the current color column also: That column shows the saved name, so if you enter a custom color but don't save a name, it saves one based on whether you're in hex or dec at that time - maybe it would've been more intuitive if I'd just used "Custom color X" as default color name. I have updated the script to change that column if you go edit the custom color names though now.
The first time you load the tool, it will be decimal - but it should save your last setting between sessions. Is it not?
You do not have the required permissions to view the files attached to this post.
Last edited by Mathew on Tue Apr 23, 2024 6:11 pm, edited 1 time in total.
-
- User
- Posts: 573
- Joined: Thu Jun 19, 2014 7:30 pm
Re: Change annotation colors tool
I think there are a few feature requests for this. Currently I don't know of a way.MedBooster wrote: ↑Mon Apr 22, 2024 7:28 pm btw... is there still no way to activate these JavaScript menus with keyboard shortcuts?
-
- User
- Posts: 1372
- Joined: Mon Nov 15, 2021 8:38 pm
Re: Change annotation colors tool
Hello Mathew,
no, even in the same session, it still loads Dec before HeX, but maybe it depends on whether you start the process or not.
no, even in the same session, it still loads Dec before HeX, but maybe it depends on whether you start the process or not.
My wishlist https://forum.pdf-xchange.com/viewtopic.php?p=187394#p187394
Disable SPACE page navigation, fix kb shortcut for highlighting advanced search tool search field, bookmarks with numbers, toolbar small icon size, AltGr/Ctrl+Alt keyboard issues
Disable SPACE page navigation, fix kb shortcut for highlighting advanced search tool search field, bookmarks with numbers, toolbar small icon size, AltGr/Ctrl+Alt keyboard issues
-
- Site Admin
- Posts: 19868
- Joined: Mon Jan 12, 2009 8:07 am
Re: Change annotation colors tool
Hello MedBooster,
For now there is still no way to get keyboard shortcuts for the custom JS code added functions.
Please do let us know if we can help with this topic in any from the PDF-XChange side
Kind regards,
Stefan
For now there is still no way to get keyboard shortcuts for the custom JS code added functions.
Please do let us know if we can help with this topic in any from the PDF-XChange side

Kind regards,
Stefan
-
- User
- Posts: 1372
- Joined: Mon Nov 15, 2021 8:38 pm
Re: Change annotation colors tool
Tracker Supp-Stefan wrote: ↑Wed Apr 24, 2024 11:24 am Hello MedBooster,
For now there is still no way to get keyboard shortcuts for the custom JS code added functions.
Please do let us know if we can help with this topic in any from the PDF-XChange side
Kind regards,
Stefan
Yes ↑ A way to preview the color in Mathew's tool. – If that's what you meant.
I understand it might be difficult to do for the enter color row, but maybe for the current color at least? To see which colors you are converting from more easily.
My wishlist https://forum.pdf-xchange.com/viewtopic.php?p=187394#p187394
Disable SPACE page navigation, fix kb shortcut for highlighting advanced search tool search field, bookmarks with numbers, toolbar small icon size, AltGr/Ctrl+Alt keyboard issues
Disable SPACE page navigation, fix kb shortcut for highlighting advanced search tool search field, bookmarks with numbers, toolbar small icon size, AltGr/Ctrl+Alt keyboard issues
-
- User
- Posts: 573
- Joined: Thu Jun 19, 2014 7:30 pm
Re: Change annotation colors tool
I don't save anything, including changes to settings, if the cancel button is pressed. If you run the tool and change only the option dec to hex, and then press OK, does it stick?MedBooster wrote: ↑Wed Apr 24, 2024 10:16 am no, even in the same session, it still loads Dec before HeX, but maybe it depends on whether you start the process or not.
-
- User
- Posts: 1372
- Joined: Mon Nov 15, 2021 8:38 pm
Re: Change annotation colors tool
Hello Mathew! Now I am convinced that it is better to not save the change if you don't run the script. It makes more sense (in general, maybe not for changing custom color names, which works great by the way!) , so please disregard my feedback.
Hopefully we could get some help with visualizing the color change by font color or some color box in the future


Hopefully we could get some help with visualizing the color change by font color or some color box in the future

My wishlist https://forum.pdf-xchange.com/viewtopic.php?p=187394#p187394
Disable SPACE page navigation, fix kb shortcut for highlighting advanced search tool search field, bookmarks with numbers, toolbar small icon size, AltGr/Ctrl+Alt keyboard issues
Disable SPACE page navigation, fix kb shortcut for highlighting advanced search tool search field, bookmarks with numbers, toolbar small icon size, AltGr/Ctrl+Alt keyboard issues
-
- Site Admin
- Posts: 11036
- Joined: Wed Jan 03, 2018 6:52 pm
Re: Change annotation colors tool

Dan McIntyre - Support Technician
PDF-XChange Co. LTD
+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
PDF-XChange Co. LTD
+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
-
- User
- Posts: 573
- Joined: Thu Jun 19, 2014 7:30 pm
Re: Change annotation colors tool
Fixed a bug that was causing the dialog to get in an infinite loop when colors were picked or edited in PXCE v10.3.
You do not have the required permissions to view the files attached to this post.
-
- Site Admin
- Posts: 19868
- Joined: Mon Jan 12, 2009 8:07 am
-
- User
- Posts: 573
- Joined: Thu Jun 19, 2014 7:30 pm
Re: Change annotation colors tool
Oops, I posted that one too quickly. Fixed another bug where if multiple colors changed at the same time, it would only take the last one.
You do not have the required permissions to view the files attached to this post.
-
- Site Admin
- Posts: 7361
- Joined: Wed Mar 25, 2009 10:37 pm
Re: Change annotation colors tool

Best regards
Paul O'Rorke
PDF-XChange Support
http://www.pdf-xchange.com
Paul O'Rorke
PDF-XChange Support
http://www.pdf-xchange.com
-
- User
- Posts: 2
- Joined: Fri May 23, 2025 7:09 pm
Re: Change annotation colors tool
Hello Matthew. I appreciate the work you put into this tool and it would be very useful to me. However, I cannot get it to work. I'm using Windows 11 and the latest version of PDF-Xchange (Version 10.6.0). I installed it as directed but the tool is greyed out. See attached screenshot. Any possible solutions?
You do not have the required permissions to view the files attached to this post.
-
- User
- Posts: 573
- Joined: Thu Jun 19, 2014 7:30 pm
Re: Change annotation colors tool
It’s greyed out if no markups are selected. Select the markups you want to change colors first, then the tool should be available.
BTW I’m working on a new version that shows the colors. Not quite done yet though
BTW I’m working on a new version that shows the colors. Not quite done yet though
-
- User
- Posts: 2
- Joined: Fri May 23, 2025 7:09 pm
-
- Site Admin
- Posts: 19868
- Joined: Mon Jan 12, 2009 8:07 am