Skip to content

PdfReader.get_form_text_fields() not returning dropdown fields #391

@akallai

Description

@akallai

I have a pdf form with multiple Form-Fields in it. The function "getFormTextFields()" is only returning a dictionary without the dropdown-fields. The dictionary contains the information of all other fields, but the dropdown-fields are simply missing.

Minimal Example

from PyPDF2 import PdfReader

reader = PdfReader("sample-files/012-libreoffice-form/libreoffice-form.pdf")
reader.get_form_text_fields()

gives

{"First Name": "Alice", "Last Name": "", "Birthday": "", "First Name_2": "Bob"}

The "Nationality" part is missing.

On the other hand:

>>> reader.get_fields()
{'First Name': {'/FT': '/Tx', '/T': 'First Name', '/V': 'Alice', '/DV': 'Alice'},
 'Last Name': {'/FT': '/Tx', '/T': 'Last Name', '/V': '', '/DV': ''}, 
'female': {'/FT': '/Btn', '/Kids': [IndirectObject(7, 0), IndirectObject(9, 0)], '/T': 'female', '/Ff': 49152, '/V': '/Off', '/DV': '/Off'},
 'Birthday': {'/FT': '/Tx', '/T': 'Birthday', '/V': '', '/DV': ''}, 
'gdpr': {'/FT': '/Btn', '/T': 'gdpr', '/V': '/Off', '/DV': '/Off'}, 
'other': {'/FT': '/Btn', '/T': 'other', '/V': '/Off', '/DV': '/Off'}, 
'First Name_2': {'/FT': '/Tx', '/T': 'First Name_2', '/Ff': 4096, '/V': 'Bob', '/DV': 'Bob'}, 
'Nationality': {'/FT': '/Ch', '/T': 'Nationality', '/Ff': 131072, '/V': '', '/DV': ''}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Has MCVEA minimal, complete and verifiable example helps a lot to debug / understand feature requestsPdfReaderThe PdfReader component is affectedis-bugFrom a users perspective, this is a bug - a violation of the expected behavior with a compliant PDFworkflow-formsFrom a users perspective, forms is the affected feature/workflow

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions