I'm trying to read text from a layer of adobe. The problem is that even if I turn off the other layers, my script still reads the text from all layers.
var layers = this.getOCGs();
var myLayer;
for(var i=0;i<layers.length;i++){
if(layers[i].name!="TheLayerIWant")
layers[i].state=false;
else{
layers[i].state=true;
myLayer=layers[i];
}
}
var word="";
for(var i=0;i<this.getPageNumWords(0);i++)
{
word=this.getPageNthWord(0,i,false);
console.println(word);
}
This script turns off all the layers except the one I need to read. Then I try to read from "TheLayerIWant", but it reads the text of all layers on that page.
What you're trying to do isn't possible using Acrobat JavaScript. All text will be read regardless of its visibility.