Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Difference in decoding of OCGs names between doc.get_ocgs() and page.get_drawings() #3143

Closed
Rodrigodd opened this issue Feb 8, 2024 · 2 comments
Labels
bug fix developed release schedule to be determined

Comments

@Rodrigodd
Copy link

Description of the bug

The list returned by doc.get_ocgs() contains the expected names of the OCGs, but the ones in the 'layer' field of the elements in page.get_drawings() are misdecoded.

How to reproduce the bug

Running the following code:

import fitz
import sys
from pprint import pprint

filename = sys.argv[1]
doc = fitz.open(filename)

pprint(doc.get_ocgs())

for page in doc:
    print('# Page:', page.number)
    print('## bboxlog layers')
    for _, _, l in page.get_bboxlog(layers=True):
        print(l)
    print('## drawing layers')
    for obj in page.get_drawings():
        print(obj.get('layer'))

With the following file:

layers-test2.pdf

Gives the following output:

PS > python .\show_layers.py .\layers-test2.pdf
{1: {'intent': [], 'name': '0', 'on': True, 'usage': None},
 2: {'intent': [], 'name': 'braço', 'on': True, 'usage': None},
 3: {'intent': [], 'name': 'braço1', 'on': True, 'usage': None},
 4: {'intent': [], 'name': 'ênvelo', 'on': True, 'usage': None},
 5: {'intent': [], 'name': 'camada', 'on': True, 'usage': None}}
# Page: 0
## bboxlog layers
0
braço
braço
braço1
ênvelo
camada
## drawing layers
0
braço
braço
braço1
ênvelo
camada

PyMuPDF version

1.23.21

Operating system

Windows

Python version

3.12

@JorjMcKie
Copy link
Collaborator

Thanks for submitting this.
We will look at it now.

@JorjMcKie JorjMcKie added bug fix developed release schedule to be determined labels Feb 9, 2024
@julian-smith-artifex-com
Copy link
Collaborator

Fixed in 1.23.22.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fix developed release schedule to be determined
Projects
None yet
Development

No branches or pull requests

3 participants