diff --git a/PyPDFForm/template.py b/PyPDFForm/template.py index 1f555235..76332368 100644 --- a/PyPDFForm/template.py +++ b/PyPDFForm/template.py @@ -102,6 +102,19 @@ def widget_rect_watermarks(pdf: bytes) -> List[bytes]: return watermarks +# def dropdown_to_text(dropdown: Dropdown) -> Text: +# """Converts a dropdown widget to a text widget.""" + +# result = Text(dropdown.name) + +# if dropdown.value is not None: +# result.value = ( +# dropdown.choices[dropdown.value] +# if dropdown.value < len(dropdown.choices) +# else "" +# ) + +# return result def dropdown_to_text(dropdown: Dropdown) -> Text: """Converts a dropdown widget to a text widget.""" @@ -109,14 +122,11 @@ def dropdown_to_text(dropdown: Dropdown) -> Text: if dropdown.value is not None: result.value = ( - dropdown.choices[dropdown.value] - if dropdown.value < len(dropdown.choices) - else "" + dropdown.value ) return result - def update_text_field_attributes( template_stream: bytes, widgets: Dict[str, WIDGET_TYPES],