Assigning a unique ID for each annotation in JS
Hi everyone,
I made a JS code to export all the annotations in a .pdf file to a .csv file and it works fine. I also need to assign a unique ID number for each row similar to a database table but couldn't figure a way out.
The issue is that if a user deletes an annotation, ID numbers of annotations after the deleted annotation will change if I use value of "i" in the "for" loop. Somehow I need to store the ID numbers in each annotation.
Let's say I have 3 annotations in a .pdf file, and run the code below;
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("-----");
}
Results are ;
1
Type:Text
Text:Comment-1
-----
2
Type:Text
Text:Comment-2
-----
3
Type:Text
Text:Comment-3
-----
If I delete the annotation-2, then the results will be;
1
Type:Text
Text:Comment-1
-----
2
Type:Text
Text:Comment-3
-----
I'm trying to keep the ID number "3" for the comment-3 even if I delete the comment-2. Is there a simple way to do that? Any kind of help is appreciated.
Regards.
