PdfArrayIterator state = aData.getMixedArray(PdfDictionary.State);
if (state != null && state.getTokenCount() > 0) {
final PdfLayerList layers = (PdfLayerList)decode_pdf.getJPedalObject(PdfDictionary.Layer);
int count = state.getTokenCount();
final int action = state.getNextValueAsConstant(true);
String ref;
for (int jj = 1; jj < count; jj++) {
ref = state.getNextValueAsString(true);
final String layerName = layers.getNameFromRef(ref);
// toggle layer status when clicked
Runnable updateAComponent = new Runnable() {
public void run() {
// force refresh
decode_pdf.invalidate();
decode_pdf.validate();
// update settings on display and in PdfDecoder
boolean newState;
if (action == PdfDictionary.Toggle)
newState = !layers.isVisible(layerName);
else if (action == PdfDictionary.OFF)
newState = false;
else //must be ON
newState = true;
layers.setVisiblity(layerName, newState);
// decode again with new settings
try {
decode_pdf.decodePage(-1);
} catch (Exception e) {