简体   繁体   中英

How to read text from a certain layer of a pdf using adobe acrobat javascript

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM