Skip to content

Commit

Permalink
Merge pull request #507 from chinapandaman/PPF-506
Browse files Browse the repository at this point in the history
PPF-506: fix filler logic for signature
  • Loading branch information
chinapandaman authored Feb 16, 2024
2 parents 5ee8c6d + 6c12c51 commit fe28357
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
11 changes: 9 additions & 2 deletions PyPDFForm/core/filler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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]
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions docs/fill.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Binary file modified image_samples/sample_signature.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pdf_samples/signature/test_fill_signature.pdf
Binary file not shown.
Binary file modified pdf_samples/signature/test_fill_signature_overlap.pdf
Binary file not shown.

0 comments on commit fe28357

Please sign in to comment.