Calculate numbers in comments

New Here ,
Dec 02, 2017

Copy link to clipboard

Copied

Is it possible to calculate numbers that is added to a documents using comments?

Like if i for instance add two comments to a document with the numbers 5 and 10. I would like the total value 15 presented in some way.

I need this function to be able to make a time estime on how much time is needed to rewrite sections in a larger document.

TOPICS
Acrobat SDK and JavaScript

Views

194

Likes

Translate

Translate

Report

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

Calculate numbers in comments

New Here ,
Dec 02, 2017

Copy link to clipboard

Copied

Is it possible to calculate numbers that is added to a documents using comments?

Like if i for instance add two comments to a document with the numbers 5 and 10. I would like the total value 15 presented in some way.

I need this function to be able to make a time estime on how much time is needed to rewrite sections in a larger document.

TOPICS
Acrobat SDK and JavaScript

Views

195

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Dec 02, 2017 0
Most Valuable Participant ,
Dec 03, 2017

Copy link to clipboard

Copied

It's possible, but not so simple. Why not use form fields?

Also, where do you want the result to appear?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 03, 2017 0
New Here ,
Dec 03, 2017

Copy link to clipboard

Copied

Thanks for the reply!

In my field of work i often send out large documents for shared review.

When i get them back they can contain hundreds of comments. Everything from small errors to big errors is covered in these reiviews.

So i would like to add a reply to each comment with info on how many hours is needed to fix each issue in the comments.

I am open for other suggestions if i can handle this in any other way.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 03, 2017 0
Most Valuable Participant ,
Dec 03, 2017

Copy link to clipboard

Copied

So you want to then add up the numbers in your replies and show them in a field, for example?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 03, 2017 0
Most Valuable Participant ,
Dec 03, 2017

Copy link to clipboard

Copied

One of the issues with doing it using a field (which is pretty much the only way I can think of) is that adding a new comment won't cause the calculation to update, which means you'll need to add a button to do it, which kind of defeats the point. You can just as well have the button display the result in an alert window.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 03, 2017 0
Most Valuable Participant ,
Dec 03, 2017

Copy link to clipboard

Copied

I've written this code to sum the values of all comments by a specific author (you can set the name on line #7) and display it in an alert. This could can be used from the Mouse Up event of a button field, for example:

var total = 0;

this.syncAnnotScan();

var annots = this.getAnnots();

if (annots!=null) {

    for (var i in annots) {

        var annot = annots;

        if (annot.author=="Me") {

            var v = annot.contents;

            if (v!=null && v!="" && !isNaN(Number(v))) {

                total+=Number(v);

            }

        }

    }

}

app.alert("Total: " + total, 3);

If you want to apply the value to a text field replace the last line with something like this:

this.getField("Total").value = total;

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 03, 2017 1
New Here ,
Dec 03, 2017

Copy link to clipboard

Copied

Thank you so much try67! Wow this is exactly what i was hoping for. I have just one minor comment: is it possible to add a word or symbol that needs to be added to the "value comment" in order for the script to compute the value? For instance "#4" or "hours 4". This would be good to separate the "value comments" from any "real" comment that might also include digits.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 03, 2017 0
try67 LATEST
Most Valuable Participant ,
Dec 03, 2017

Copy link to clipboard

Copied

The code above will not add any numbers it finds in any comment, only those comments that contain only a number.

It is possible to have it only process things like "hours 4" (why not "4 hours", by the way?), but that would make it more complicated.

I think that the code above should be enough, especially since it's limited to only comments made by a specific author.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 03, 2017 0
New Here ,
Dec 03, 2017

Copy link to clipboard

Copied

Wow.  I must be asking the wrong question.  This question seems like the same question I asked, but I have no suggestions.  Perhaps I can piggyback on this one.  If this is possible for form fields to recognize comments and make a calculation from those comments, can you help me understand how this is done?  PLEASE.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 03, 2017 0
Most Valuable Participant ,
Dec 03, 2017

Copy link to clipboard

Copied

As I wrote, this is not simple. Based on what do you want to recognize which comments to add up? Where do you want to display the result?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 03, 2017 0
New Here ,
Dec 03, 2017

Copy link to clipboard

Copied

I am basically looking at the same situation.  I have very large files that I created a summary form report for.  I have added this one page summary to the top of all of my files.  Much of the info is autofill, but I am seeking a way for the form to target text in a comment that matches one of the options on the form and simply mark it with a check stating that this information was found within that file.  This is for the purposes of medical records and marking compliant information present or not. I'm hoping a javascript can do within the checkbox field.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 03, 2017 0
Most Valuable Participant ,
Dec 03, 2017

Copy link to clipboard

Copied

Sorry, this it too vague. I'll need to see the actual file to say for sure if it's possible or not.

You can contact me at try6767 at gmail.com to discuss it further.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 03, 2017 0
New Here ,
Dec 03, 2017

Copy link to clipboard

Copied

I will do this.  Thanks a million try67.  And thanks a million to you marcusss79 for asking your question and getting attention to the subject I was seeking.  My apologies for any deterrence this may have caused from your questions.  Enjoy the holidays. 🙂

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 03, 2017 0