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

Reading CheckMark State

Guest
Mar 31, 2016 Mar 31, 2016

Hi everyone,

I'm trying to get the state of CheckMark in JavaScript. As per JS API reference, code as below should be used and it works fine.

annots = this.getAnnots()

   for ( var i= 0; i< annots.length; i++) {

      states = annots.getStateInModel("Marked");

      if ( states.length > 0 ) {

         for(j = 0; j < states.length; j++)

         {

            var s = states.state;       

            console.println(s );

         }

  

      }  

   }

But as you know, CheckMark is also a part of an annotation( Sticky Note, Highlight, etc.). When I try to read the same state under the related annotation with InReplyTo, I get nothing.

annots = this.getAnnots()

mark = this.getAnnots()

   for ( var i= 0; i< annots.length; i++) {

         for ( var j= 0; j< mark.length; j++) {

                 if(mark.inReplyTo == annots.name){

                 states = mark.getStateInModel("Marked");

                   if ( states.length > 0 ) {

                      for(k = 0; k < states.length; k++)

                          {

                           var s = states.state;

                           console.println(s)

                           }  

                      }

                 } 

            }

   }

I couldn't figure out what is wrong with this code? Any help is appreciated.

Regards

TOPICS
Acrobat SDK and JavaScript , Windows
996
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

correct answers 1 Correct answer

Community Expert , Mar 31, 2016 Mar 31, 2016

You don't need to do that. The thing is, though, that checking the reply itself seems to generate an new, separate reply annotation...

I create a file with a comment and a reply and then checked the box of the reply. I then ran this version of your first code on it:

this.syncAnnotScan();

var annots = this.getAnnots()

for ( var i= 0; i< annots.length; i++) {

    console.println(i+1);

    console.println("Type:"+annots.type);

    console.println("Text:"+annots.contents);

    console.println("Reply:

...
Translate
Community Expert ,
Mar 31, 2016 Mar 31, 2016

Are you talking about a check-box? If so, it's not an annotation at all. It's a field, and you access its value like this (let's say its name is "CheckBox1"):

this.getField("CheckBox1").value

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
Guest
Mar 31, 2016 Mar 31, 2016

Nope, I'm talking about CheckMark inside a comment. Please see picture below

CheckMark.png

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 ,
Mar 31, 2016 Mar 31, 2016

I see what you mean. Unfortunately, I don't think you can access that information using a 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
Guest
Mar 31, 2016 Mar 31, 2016

Dear try67, it is possible to access that info. It is stored under statemodel array of the annotation.

If you check the exported xfdf file of annotations, you can see something like that as below;

"inreplyto="03edbc7f-2608-462d-a1ee-0ce95d03e9ab" name="765594c1-0f1d-4456-9cdf-bdb184afb3c8" state="Marked" statemodel="Marked""

I can read this value with the first code above, but cant read it with the second code above which doesn't make sense at all.

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 ,
Mar 31, 2016 Mar 31, 2016

That's interesting. I wasn't aware do the "Marked" model-state... I'm looking into your second code now.

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 ,
Mar 31, 2016 Mar 31, 2016

Can you explain a bit what you're trying to achieve with this code? You should be getting all the annotations, including the replies, when you use getAnnots... Are you trying to find annots that are both replies and checked?

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
Guest
Mar 31, 2016 Mar 31, 2016

My main goal is to export all the comments into an excel file.

If a comment is checked, in the same row of the excel file user will see his comment and see if it is checked.

So I need to get all the annotations and check if it is checked or not. Thats why I need to use second code 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 Expert ,
Mar 31, 2016 Mar 31, 2016

You don't need to do that. The thing is, though, that checking the reply itself seems to generate an new, separate reply annotation...

I create a file with a comment and a reply and then checked the box of the reply. I then ran this version of your first code on it:

this.syncAnnotScan();

var annots = this.getAnnots()

for ( var i= 0; i< annots.length; i++) {

    console.println(i+1);

    console.println("Type:"+annots.type);

    console.println("Text:"+annots.contents);

    console.println("Reply:"+(annots.inReplyTo=="" ? "false" : "true"));

    states = annots.getStateInModel("Marked");

    if ( states.length > 0 ) {

        for(j = 0; j < states.length; j++) {

            var s = states.state;    

            console.println("State:"+s);

        }

    }

    console.println("-----");

}

The results were:

1

Type:Text

Text:master comment

Reply:false

-----

2

Type:Text

Text:reply to master comment

Reply:true

State:Marked

-----

3

Type:Text

Text:Marked set by Gilad

Reply:true

-----

As you can see there are now two "reply" annotations, one that has the actual text I added, and another one that contains an automatic text that is generated when you check the box.

The weird thing is that only the first one has its state set as "Marked"... Another weird thing is that if I delete the master comment and the reply, that third one still remains, even though the Comments list is now empty.

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
Guest
Mar 31, 2016 Mar 31, 2016
LATEST

Now I see the problem in my code.

Since the state="marked" can be seen in automatic generated check box text annotation in the .xfdf file, I tought that I need to read this state from that check box annotation, but it is still stored in the master comment.

Thank you so much try67, everything is clear now. I am aware of the weird behaviour of this CheckBox. I gotta figure out a way to filter them in the script if the master comment is deleted.

Regards

Emre

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