-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Explanation
While updating my app, something changed causing an error within pypdf. The issue was due to the dictionary of fields I was sending into update_page_form_field_values
, that was previously a mix of strings, integers, and float values. I discovered the note in the doc-string that the function expected a string, list of strings or a tuple.
Correcting this fixed my issue, but it took some time to find as the error was nested, and that the typing on fields is Any, especially since floats worked previously.
Updating the typing from Any to the expected types could be helpful to anyone else with this problem. Or another suggestion would be to coerce to a string type on TextStringObject simply by calling str() on the value
Either way my issue is fixed, I love this package!
Code Example
Line 1047 in de5d115
def update_page_form_field_values( |
def update_page_form_field_values(
self,
page: Union[PageObject, List[PageObject], None],
fields: Dict[str, Union[str, List[str], Tuple[str, str, float]]],
flags: FA.FfBits = FFBITS_NUL,
auto_regenerate: Optional[bool] = True,
) -> None:
OR
Line 632 in de5d115
class TextStringObject(str, PdfObject): # noqa: SLOT000 |
def __new__(cls, value: Any) -> "TextStringObject":
value=str(value)
...