diff --git a/PyPDFForm/core/filler.py b/PyPDFForm/core/filler.py index a09dcfb1..366c21d4 100644 --- a/PyPDFForm/core/filler.py +++ b/PyPDFForm/core/filler.py @@ -41,6 +41,7 @@ def fill( for _widget in _widgets: key = get_widget_key(_widget) text_needs_to_be_drawn = False + _to_draw = x = y = None if isinstance(widgets[key], (Checkbox, Radio)): font_size = checkbox_radio_font_size(_widget) @@ -69,7 +70,6 @@ def fill( height, ] ) - text_needs_to_be_drawn = False else: widgets[key].text_line_x_coordinates = get_text_line_x_coordinates( _widget, widgets[key] @@ -78,7 +78,14 @@ def fill( _to_draw = widgets[key] text_needs_to_be_drawn = True - if text_needs_to_be_drawn: + if all( + [ + text_needs_to_be_drawn, + _to_draw is not None, + x is not None, + y is not None, + ] + ): texts_to_draw[page].append( [ _to_draw, diff --git a/docs/fill.md b/docs/fill.md index 4cf5e432..0761fe9f 100644 --- a/docs/fill.md +++ b/docs/fill.md @@ -90,5 +90,5 @@ with open("output.pdf", "wb+") as output: output.write(signed.read()) ``` -**NOTE:** As described [here](install.md/#create-a-pdf-wrapper), the value of the signature in your dictionary can be a file path shown above, but also an open file object and a file stream -that's in `bytes`. +**NOTE:** As described [here](install.md/#create-a-pdf-wrapper), the value of the signature in your dictionary can be +a file path shown above, but also an open file object and a file stream that's in `bytes`. diff --git a/image_samples/sample_signature.png b/image_samples/sample_signature.png index 44d9f9ee..532628af 100644 Binary files a/image_samples/sample_signature.png and b/image_samples/sample_signature.png differ diff --git a/pdf_samples/signature/test_fill_signature.pdf b/pdf_samples/signature/test_fill_signature.pdf index 68d39155..ee0a72bc 100644 Binary files a/pdf_samples/signature/test_fill_signature.pdf and b/pdf_samples/signature/test_fill_signature.pdf differ diff --git a/pdf_samples/signature/test_fill_signature_overlap.pdf b/pdf_samples/signature/test_fill_signature_overlap.pdf index 2d8faca3..092cb9e2 100644 Binary files a/pdf_samples/signature/test_fill_signature_overlap.pdf and b/pdf_samples/signature/test_fill_signature_overlap.pdf differ