PyMuPDF icon indicating copy to clipboard operation
PyMuPDF copied to clipboard

ComboBox choice_values full of empty strings despite PDF having valid choices.

Open sarahkittyy opened this issue 10 months ago • 3 comments

Description of the bug

I am using the 940b: https://www.irs.gov/pub/irs-pdf/f940b.pdf

The PDF file has identical pages, and each page has this specific dropdown: image

The choice_values variable is empty.

import pymupdf

pdf = pymupdf.open('f940b.pdf')

for page in pdf:
    for widget in page.widgets():
        if widget.field_type_string == 'ComboBox':
            print(widget.choice_values)
        widget.update()
pdf.save('f940b-output.pdf')

Expected output:

[' - Select One - ', '  ', 'Cincinnati, OH 45999', 'Memphis, TN 37501', 'Ogden, UT 84201', 'Philadelphia, PA 19255']
[' - Select One - ', '  ', 'Cincinnati, OH 45999', 'Memphis, TN 37501', 'Ogden, UT 84201', 'Philadelphia, PA 19255']

Actual output:

['', '', '', '', '', '']
[' - Select One - ', '  ', 'Cincinnati, OH 45999', 'Memphis, TN 37501', 'Ogden, UT 84201', 'Philadelphia, PA 19255']

This also affects the resulting f940b-output.pdf, where the first combo box is suddenly completely empty with no choices available. image

How to reproduce the bug

See above

PyMuPDF version

1.24.13

Operating system

Linux

Python version

3.12

sarahkittyy avatar Dec 04 '24 21:12 sarahkittyy