Skip to main content
Document Geek
Community Expert
Community Expert
September 1, 2017
Answered

Change Icon of sticky note based on Content

  • September 1, 2017
  • 4 replies
  • 3021 views

I'm looking for an easy solution to better manage the appearance of my sticky notes. In a previous post, I was able to get help changing sticky note color based on content. It works great!

I am now looking for a way to change sticky note icon based on content. Currently, all my sticky notes are the "Text Note" icon (because that's how they are exported from InDesign). But I'd like to be able to easily and globally change the Text Note icon to any of the other icons.

It would be even more amazing if the script could also delete the text associated with the color.

For example. If the sticky note content starts with "Help:" the Text Note icon would change to the Help icon, and then also delete "Help:" from the beginning of the sticky note contents.

This topic has been closed for replies.
Correct answer try67

This code will do that. You can expand it to process more icons and texts, of course.

this.syncAnnotScan();

var annots = this.getAnnots();

if (annots!=null) {

    for (var i in annots) {

        var annot = annots;

        if (annot.type=="Text") {

            if (/^Help:/.test(annot.contents)) {

                annot.contents = annot.contents.replace(/^Help:/, "");

                annot.noteIcon = "Help";

            }

        }

    }

}

4 replies

Joel Geraci
Community Expert
Community Expert
January 18, 2018

One thing to be aware of. The icons named Comment, Key, Note, Help, NewParagraph, Paragraph, and Insert are the only ones provided by the viewer if no appearance is supplied in the annotation. In other PDF viewers, they may not look exactly like the icons provided by Acrobat and Reader.

Document Geek
Community Expert
Community Expert
January 18, 2018

What is "viewer"?The software serving to display the PDF? Or the person viewing the PDF? I don't understand.

This goes for all PDF viewers?

Regardless, the icons only need to be seen in Acrobat. I I don't care how they look in Preview, Bluebeam, Goodreader, etc.

Joel Geraci
Community Expert
Community Expert
January 18, 2018

Ok - If it's only Acrobat and Reader, you're good.

JR Boulay
Community Expert
Community Expert
January 18, 2018

made a nice presentation of Acrobat's Comment tools yesterday.

Everyone should see the recording: Tech Wednesday Acrobat

Acrobate du PDF, InDesigner et Photoshopographe
Document Geek
Community Expert
Community Expert
January 18, 2018

I am still trying to get the script to work successfully with all the icons. Is there any part of the script that is redundant and doesn't need to be duplicated?

this.syncAnnotScan(); 

var annots = this.getAnnots(); 

if (annots!=null) { 

    for (var i in annots) { 

        var annot = annots

        if (annot.type=="Text") { 

            if (/^Help:/.test(annot.contents)) { 

                annot.contents = annot.contents.replace(/^Help:/, ""); 

                annot.noteIcon = "Help"; 

            } 

        } 

    } 

this.syncAnnotScan();

var annots = this.getAnnots(); 

if (annots!=null) { 

    for (var i in annots) { 

        var annot = annots

        if (annot.type=="Text") { 

            if (/^Star:/.test(annot.contents)) { 

                annot.contents = annot.contents.replace(/^Star:/, ""); 

                annot.noteIcon = "Star"; 

            } 

        } 

    } 

try67
Community Expert
Community Expert
January 18, 2018

Yes, almost all of the second part is redundant. Use this:

this.syncAnnotScan();  

var annots = this.getAnnots();  

if (annots!=null) {  

    for (var i in annots) {  

        var annot = annots;  

        if (annot.type=="Text") {  

            if (/^Help:/.test(annot.contents)) {  

                annot.contents = annot.contents.replace(/^Help:/, "");  

                annot.noteIcon = "Help";  

            }

            else if (/^Star:/.test(annot.contents)) {  

                annot.contents = annot.contents.replace(/^Star:/, "");  

                annot.noteIcon = "Star";  

            }          

        }  

    }  

}  

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
September 1, 2017

This code will do that. You can expand it to process more icons and texts, of course.

this.syncAnnotScan();

var annots = this.getAnnots();

if (annots!=null) {

    for (var i in annots) {

        var annot = annots;

        if (annot.type=="Text") {

            if (/^Help:/.test(annot.contents)) {

                annot.contents = annot.contents.replace(/^Help:/, "");

                annot.noteIcon = "Help";

            }

        }

    }

}

Document Geek
Community Expert
Community Expert
September 1, 2017

That's amazing! Thank you so much!

Document Geek
Community Expert
Community Expert
September 12, 2017

On a related question: I am trying to combine the Change sticky note color based on content script with this one. I have exported a bunch of sticky notes as an FDF file, but I can't figure out where in the code the color is referenced.

Which part of this references color?

<</C[0.639221 0.188232 0.525497]/Contents(Purple: 7)/CreationDate(D:20170912144332-04'00')/F 28/M(D:20170912145013-04'00')/NM(4e8a7e30-c615-ff43-86da-19659fa1a871)/Name/Comment/Page 4/Popup 15 0 R/RC(<?xml version="1.0"?><body xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:APIVersion="Acrobat:17.12.0" xfa:spec="2.0.2" ><p dir="ltr"><span dir="ltr" style="font-size:13.2pt;text-align:left;color:#000000;font-\

weight:normal;font-style:normal">Purple: 7</span></p></body>)/Rect[52.7047 328.113 70.7047 346.113]/Subtype/Text/T(kellyvaughn)/Type/Annot>>