Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

Editing PDF comments with JS console

Community Beginner ,
Feb 17, 2022 Feb 17, 2022

I tried to use the JS script on this page from a few years ago:

https://community.adobe.com/t5/acrobat-discussions/batch-edit-properties-on-existing-comments/m-p/99...

I'll copy it here:

 

this.syncAnnotScan();

var annots = this.getAnnots();

if (annots!=null) {

    for (var i in annots) {

        var annot = annots;

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

            var annotContents = annot.richContents;

            for (var j in annotContents) {

                annotContents.textColor = color.green;

            }

            annot.setProps({richContents: annotContents});

        }

    }

}

 

But it is not working for me. Is there some way to update this script to get it to work with the latest version of Acrobat?

TOPICS
JavaScript
1.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Feb 18, 2022 Feb 18, 2022

You're right. It seems the forums system corrupted the code... It should be:

 

this.syncAnnotScan();
var annots = this.getAnnots();
if (annots!=null) {
    for (var i in annots) {
        var annot = annots[i];
        if (annot.type=="FreeText") {
            var annotContents = annot.richContents;
            for (var j in annotContents) {
                annotContents[j].textColor = color.green;
            }
            annot.setProps({richContents: annotContents});
        }
    }
}

 

I also fixed it in the original thread linked to above.

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 17, 2022 Feb 17, 2022

Looks like something I wrote... It should still work. What happens when you run it?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 17, 2022 Feb 17, 2022

It just says 'undefined' and there's no change.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 17, 2022 Feb 17, 2022

Be sure to select All before running code. It only runs selected lines. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 17, 2022 Feb 17, 2022

Does your file contain "Free Text" comments, added using the "Add Text Comment" tool? Because this code will only edit those.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 17, 2022 Feb 17, 2022

Yes, exactly. Added with the "Add Text Comment" tool.  

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 17, 2022 Feb 17, 2022

You doesn't use the variables i and j in the script.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 18, 2022 Feb 18, 2022

You're right. It seems the forums system corrupted the code... It should be:

 

this.syncAnnotScan();
var annots = this.getAnnots();
if (annots!=null) {
    for (var i in annots) {
        var annot = annots[i];
        if (annot.type=="FreeText") {
            var annotContents = annot.richContents;
            for (var j in annotContents) {
                annotContents[j].textColor = color.green;
            }
            annot.setProps({richContents: annotContents});
        }
    }
}

 

I also fixed it in the original thread linked to above.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 18, 2022 Feb 18, 2022
LATEST

That was it. It works! Thank you both for the solution.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines