Copy link to clipboard
Copied
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
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
states = mark
if ( states.length > 0 ) {
for(k = 0; k < states.length; k++)
{
var s = states
console.println(s)
}
}
}
}
}
I couldn't figure out what is wrong with this code? Any help is appreciated.
Regards
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:
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Nope, I'm talking about CheckMark inside a comment. Please see picture below
Copy link to clipboard
Copied
I see what you mean. Unfortunately, I don't think you can access that information using a script.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
That's interesting. I wasn't aware do the "Marked" model-state... I'm looking into your second code now.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Find more inspiration, events, and resources on the new Adobe Community
Explore Now