Skip to content

set_layer_ui_config() toggles all layers rather than just one #4479

Closed
@kiddfc

Description

@kiddfc

temp_file.ai.zip

Description of the bug

After version 1.25.0, set_layer_ui_config() toggles the display for all layers rather than just the given layer.

A similar issue was also discussed in #4348.

How to reproduce the bug

For version 1.24.14:
pdf_document.layer_ui_configs() returns:

[
  {'depth': 0, 'locked': 0, 'number': 0, 'on': 1, 'text': 'layer_0', 'type': 'checkbox'},
  {'depth': 0, 'locked': 0, 'number': 1, 'on': 1, 'text': 'layer_1', 'type': 'checkbox'},
  {'depth': 0, 'locked': 0, 'number': 2, 'on': 0, 'text': 'layer_2', 'type': 'checkbox'},
  {'depth': 0, 'locked': 0, 'number': 3, 'on': 1, 'text': 'layer_3', 'type': 'checkbox'},
  {'depth': 0, 'locked': 0, 'number': 4, 'on': 1, 'text': 'layer_4', 'type': 'checkbox'},
  {'depth': 0, 'locked': 0, 'number': 5, 'on': 1, 'text': 'layer_5', 'type': 'checkbox'},
  {'depth': 0, 'locked': 0, 'number': 6, 'on': 1, 'text': 'layer_6', 'type': 'checkbox'},
  {'depth': 0, 'locked': 0, 'number': 7, 'on': 1, 'text': 'layer_7', 'type': 'checkbox'}
]

I call pdf_document.set_layer_ui_config(0, fitz.PDF_OC_OFF), then pdf_document.layer_ui_configs(). It returns:

[
  {'depth': 0, 'locked': 0, 'number': 0, 'on': 0, 'text': 'layer_0', 'type': 'checkbox'},
  {'depth': 0, 'locked': 0, 'number': 1, 'on': 1, 'text': 'layer_1', 'type': 'checkbox'},
  {'depth': 0, 'locked': 0, 'number': 2, 'on': 0, 'text': 'layer_2', 'type': 'checkbox'},
  {'depth': 0, 'locked': 0, 'number': 3, 'on': 1, 'text': 'layer_3', 'type': 'checkbox'},
  {'depth': 0, 'locked': 0, 'number': 4, 'on': 1, 'text': 'layer_4', 'type': 'checkbox'},
  {'depth': 0, 'locked': 0, 'number': 5, 'on': 1, 'text': 'layer_5', 'type': 'checkbox'},
  {'depth': 0, 'locked': 0, 'number': 6, 'on': 1, 'text': 'layer_6', 'type': 'checkbox'},
  {'depth': 0, 'locked': 0, 'number': 7, 'on': 1, 'text': 'layer_7', 'type': 'checkbox'}
]

This is the expected behaviour.

Then I try the same commands with version 1.25.0:
pdf_document.layer_ui_configs() returns:

[
  {'depth': 0, 'locked': 0, 'number': 0, 'on': 1, 'text': 'layer_0', 'type': 'checkbox'},
  {'depth': 0, 'locked': 0, 'number': 1, 'on': 1, 'text': 'layer_1', 'type': 'checkbox'},
  {'depth': 0, 'locked': 0, 'number': 2, 'on': 1, 'text': 'layer_2', 'type': 'checkbox'},
  {'depth': 0, 'locked': 0, 'number': 3, 'on': 1, 'text': 'layer_3', 'type': 'checkbox'},
  {'depth': 0, 'locked': 0, 'number': 4, 'on': 1, 'text': 'layer_4', 'type': 'checkbox'},
  {'depth': 0, 'locked': 0, 'number': 5, 'on': 1, 'text': 'layer_5', 'type': 'checkbox'},
  {'depth': 0, 'locked': 0, 'number': 6, 'on': 1, 'text': 'layer_6', 'type': 'checkbox'},
  {'depth': 0, 'locked': 0, 'number': 7, 'on': 1, 'text': 'layer_7', 'type': 'checkbox'}
]

There is already a problem here, layer_2 should have 'on': 0, but it shows as 'on': 1.
I call pdf_document.set_layer_ui_config(0, fitz.PDF_OC_OFF), then pdf_document.layer_ui_configs(). It returns:

[
  {'depth': 0, 'locked': 0, 'number': 0, 'on': 0, 'text': 'layer_0', 'type': 'checkbox'},
  {'depth': 0, 'locked': 0, 'number': 1, 'on': 0, 'text': 'layer_1', 'type': 'checkbox'},
  {'depth': 0, 'locked': 0, 'number': 2, 'on': 0, 'text': 'layer_2', 'type': 'checkbox'},
  {'depth': 0, 'locked': 0, 'number': 3, 'on': 0, 'text': 'layer_3', 'type': 'checkbox'},
  {'depth': 0, 'locked': 0, 'number': 4, 'on': 0, 'text': 'layer_4', 'type': 'checkbox'},
  {'depth': 0, 'locked': 0, 'number': 5, 'on': 0, 'text': 'layer_5', 'type': 'checkbox'},
  {'depth': 0, 'locked': 0, 'number': 6, 'on': 0, 'text': 'layer_6', 'type': 'checkbox'},
  {'depth': 0, 'locked': 0, 'number': 7, 'on': 0, 'text': 'layer_7', 'type': 'checkbox'}
]

Please let me know if you need any other information.

PyMuPDF version

1.25.0

Operating system

MacOS

Python version

3.12

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions