简体   繁体   中英

Adobe Acrobat Javascript Forms - Show/Hide layers in multiple pages

I'm using javascript language to make a Adobe Acrobat Forms with layers. I have a problem with show/hide this layers when it is a multiple page document when it is a page it's working fine.

The idea is:

I have a PDF document with two pages. I have a combobox in the page 1. I have three layers in the page 2. When I choose an option of this combobox show or hide layers of the page 2.

The code is running of combobox with the event validate of the propierties:

var layers = this.getOCGs(0); 

if (event.value == "NAP") {
    layers[0].state = true;
    layers[1].state = false;
    layers[2].state = false;

}else if(event.value == "MOD"){

    layers[0].state = false;
    layers[1].state = true;
    layers[2].state = false;

}else if(event.value == "NIT"){

    layers[0].state = false;
    layers[1].state = false;
    layers[2].state = true;

}else{

    layers[0].state = false;
    layers[1].state = false;
    layers[2].state = false;
}

I see the debug console an show this message:

TypeError: layers is null

I do not understand why it's working fine when the document is only a page and it's not working fine when the document are two pages or more.

Please Could you help me?

Thanks!

That first line of code will return the layers on the first page. If you want to get the layers on the second page, use 1 as the parameter instead of 0.

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