PyPDFForm 1.4.32__tar.gz → 1.4.33__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of PyPDFForm might be problematic. Click here for more details.

Files changed (47) hide show
  1. {pypdfform-1.4.32 → pypdfform-1.4.33}/PKG-INFO +1 -1
  2. {pypdfform-1.4.32 → pypdfform-1.4.33}/PyPDFForm/__init__.py +1 -1
  3. {pypdfform-1.4.32 → pypdfform-1.4.33}/PyPDFForm/image.py +1 -1
  4. {pypdfform-1.4.32 → pypdfform-1.4.33}/PyPDFForm/patterns.py +15 -3
  5. {pypdfform-1.4.32 → pypdfform-1.4.33}/PyPDFForm/widgets/base.py +3 -1
  6. {pypdfform-1.4.32 → pypdfform-1.4.33}/PyPDFForm/widgets/text.py +1 -1
  7. {pypdfform-1.4.32 → pypdfform-1.4.33}/PyPDFForm.egg-info/PKG-INFO +1 -1
  8. {pypdfform-1.4.32 → pypdfform-1.4.33}/tests/test_create_widget.py +24 -0
  9. {pypdfform-1.4.32 → pypdfform-1.4.33}/LICENSE +0 -0
  10. {pypdfform-1.4.32 → pypdfform-1.4.33}/PyPDFForm/adapter.py +0 -0
  11. {pypdfform-1.4.32 → pypdfform-1.4.33}/PyPDFForm/constants.py +0 -0
  12. {pypdfform-1.4.32 → pypdfform-1.4.33}/PyPDFForm/coordinate.py +0 -0
  13. {pypdfform-1.4.32 → pypdfform-1.4.33}/PyPDFForm/filler.py +0 -0
  14. {pypdfform-1.4.32 → pypdfform-1.4.33}/PyPDFForm/font.py +0 -0
  15. {pypdfform-1.4.32 → pypdfform-1.4.33}/PyPDFForm/middleware/__init__.py +0 -0
  16. {pypdfform-1.4.32 → pypdfform-1.4.33}/PyPDFForm/middleware/base.py +0 -0
  17. {pypdfform-1.4.32 → pypdfform-1.4.33}/PyPDFForm/middleware/checkbox.py +0 -0
  18. {pypdfform-1.4.32 → pypdfform-1.4.33}/PyPDFForm/middleware/dropdown.py +0 -0
  19. {pypdfform-1.4.32 → pypdfform-1.4.33}/PyPDFForm/middleware/image.py +0 -0
  20. {pypdfform-1.4.32 → pypdfform-1.4.33}/PyPDFForm/middleware/radio.py +0 -0
  21. {pypdfform-1.4.32 → pypdfform-1.4.33}/PyPDFForm/middleware/signature.py +0 -0
  22. {pypdfform-1.4.32 → pypdfform-1.4.33}/PyPDFForm/middleware/text.py +0 -0
  23. {pypdfform-1.4.32 → pypdfform-1.4.33}/PyPDFForm/template.py +0 -0
  24. {pypdfform-1.4.32 → pypdfform-1.4.33}/PyPDFForm/utils.py +0 -0
  25. {pypdfform-1.4.32 → pypdfform-1.4.33}/PyPDFForm/watermark.py +0 -0
  26. {pypdfform-1.4.32 → pypdfform-1.4.33}/PyPDFForm/widgets/__init__.py +0 -0
  27. {pypdfform-1.4.32 → pypdfform-1.4.33}/PyPDFForm/widgets/checkbox.py +0 -0
  28. {pypdfform-1.4.32 → pypdfform-1.4.33}/PyPDFForm/widgets/dropdown.py +0 -0
  29. {pypdfform-1.4.32 → pypdfform-1.4.33}/PyPDFForm/wrapper.py +0 -0
  30. {pypdfform-1.4.32 → pypdfform-1.4.33}/PyPDFForm.egg-info/SOURCES.txt +0 -0
  31. {pypdfform-1.4.32 → pypdfform-1.4.33}/PyPDFForm.egg-info/dependency_links.txt +0 -0
  32. {pypdfform-1.4.32 → pypdfform-1.4.33}/PyPDFForm.egg-info/requires.txt +0 -0
  33. {pypdfform-1.4.32 → pypdfform-1.4.33}/PyPDFForm.egg-info/top_level.txt +0 -0
  34. {pypdfform-1.4.32 → pypdfform-1.4.33}/README.md +0 -0
  35. {pypdfform-1.4.32 → pypdfform-1.4.33}/setup.cfg +0 -0
  36. {pypdfform-1.4.32 → pypdfform-1.4.33}/setup.py +0 -0
  37. {pypdfform-1.4.32 → pypdfform-1.4.33}/tests/test_adobe_mode.py +0 -0
  38. {pypdfform-1.4.32 → pypdfform-1.4.33}/tests/test_dropdown.py +0 -0
  39. {pypdfform-1.4.32 → pypdfform-1.4.33}/tests/test_dropdown_simple.py +0 -0
  40. {pypdfform-1.4.32 → pypdfform-1.4.33}/tests/test_fill_max_length_text_field.py +0 -0
  41. {pypdfform-1.4.32 → pypdfform-1.4.33}/tests/test_fill_max_length_text_field_simple.py +0 -0
  42. {pypdfform-1.4.32 → pypdfform-1.4.33}/tests/test_functional.py +0 -0
  43. {pypdfform-1.4.32 → pypdfform-1.4.33}/tests/test_functional_simple.py +0 -0
  44. {pypdfform-1.4.32 → pypdfform-1.4.33}/tests/test_paragraph.py +0 -0
  45. {pypdfform-1.4.32 → pypdfform-1.4.33}/tests/test_paragraph_simple.py +0 -0
  46. {pypdfform-1.4.32 → pypdfform-1.4.33}/tests/test_preview.py +0 -0
  47. {pypdfform-1.4.32 → pypdfform-1.4.33}/tests/test_signature.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyPDFForm
3
- Version: 1.4.32
3
+ Version: 1.4.33
4
4
  Summary: The Python library for PDF forms.
5
5
  Home-page: https://github.com/chinapandaman/PyPDFForm
6
6
  Author: Jinge Li
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  """Contains any object users might need."""
3
3
 
4
- __version__ = "1.4.32"
4
+ __version__ = "1.4.33"
5
5
 
6
6
  from .wrapper import FormWrapper, PdfWrapper
7
7
 
@@ -42,7 +42,7 @@ def any_image_to_jpg(image_stream: bytes) -> bytes:
42
42
  return image_stream
43
43
 
44
44
  rgb_image = Image.new("RGB", image.size, (255, 255, 255))
45
- rgb_image.paste(image, mask=image.split()[3])
45
+ rgb_image.paste(image, mask=image.split()[3] if len(image.split()) == 4 else None)
46
46
 
47
47
  with BytesIO() as _file:
48
48
  rgb_image.save(_file, format="JPEG")
@@ -5,8 +5,8 @@ from pypdf.generic import (DictionaryObject, NameObject, NumberObject,
5
5
  TextStringObject)
6
6
 
7
7
  from .constants import (AP, AS, CA, DA, DV, FT, IMAGE_FIELD_IDENTIFIER, JS, MK,
8
- READ_ONLY, A, Btn, Ch, Ff, N, Off, Opt, Parent, Q, Sig,
9
- T, Tx, V, Yes)
8
+ MULTILINE, READ_ONLY, A, Btn, Ch, Ff, N, Off, Opt,
9
+ Parent, Q, Sig, T, Tx, V, Yes)
10
10
  from .middleware.checkbox import Checkbox
11
11
  from .middleware.dropdown import Dropdown
12
12
  from .middleware.image import Image
@@ -166,4 +166,16 @@ def update_created_text_field_alignment(annot: DictionaryObject, val: int) -> No
166
166
  annot[NameObject(Q)] = NumberObject(val)
167
167
 
168
168
 
169
- NON_ACRO_FORM_PARAM_TO_FUNC = {"alignment": update_created_text_field_alignment}
169
+ def update_created_text_field_multiline(annot: DictionaryObject, val: bool) -> None:
170
+ """Patterns to update to multiline for text annotations created by the library."""
171
+
172
+ if val:
173
+ annot[NameObject(Ff)] = NumberObject(
174
+ int(annot[NameObject(Ff)]) | MULTILINE # noqa
175
+ )
176
+
177
+
178
+ NON_ACRO_FORM_PARAM_TO_FUNC = {
179
+ ("TextWidget", "alignment"): update_created_text_field_alignment,
180
+ ("TextWidget", "multiline"): update_created_text_field_multiline,
181
+ }
@@ -59,7 +59,9 @@ class Widget:
59
59
 
60
60
  for each in self.ALLOWED_NON_ACRO_FORM_PARAMS:
61
61
  if each in kwargs:
62
- self.non_acro_form_params.append((each, kwargs.get(each)))
62
+ self.non_acro_form_params.append(
63
+ ((type(self).__name__, each), kwargs.get(each))
64
+ )
63
65
 
64
66
  def watermarks(self, stream: bytes) -> List[bytes]:
65
67
  """Returns a list of watermarks after creating the widget."""
@@ -19,6 +19,6 @@ class TextWidget(Widget):
19
19
  ("max_length", "maxlen"),
20
20
  ]
21
21
  COLOR_PARAMS = ["font_color", "bg_color", "border_color"]
22
- ALLOWED_NON_ACRO_FORM_PARAMS = ["alignment"]
22
+ ALLOWED_NON_ACRO_FORM_PARAMS = ["alignment", "multiline"]
23
23
  NONE_DEFAULTS = ["max_length"]
24
24
  ACRO_FORM_FUNC = "textfield"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyPDFForm
3
- Version: 1.4.32
3
+ Version: 1.4.33
4
4
  Summary: The Python library for PDF forms.
5
5
  Home-page: https://github.com/chinapandaman/PyPDFForm
6
6
  Author: Jinge Li
@@ -242,6 +242,30 @@ def test_create_text_align_right(template_stream, pdf_samples, request):
242
242
  assert obj.stream == expected
243
243
 
244
244
 
245
+ def test_create_text_align_multiline(template_stream, pdf_samples, request):
246
+ expected_path = os.path.join(
247
+ pdf_samples, "widget", "create_text_align_multiline.pdf"
248
+ )
249
+ with open(expected_path, "rb+") as f:
250
+ obj = PdfWrapper(template_stream).create_widget(
251
+ "text",
252
+ "foo",
253
+ 1,
254
+ 100,
255
+ 100,
256
+ multiline=True,
257
+ )
258
+ assert obj.schema["properties"]["foo"]["type"] == "string"
259
+
260
+ request.config.results["expected_path"] = expected_path
261
+ request.config.results["stream"] = obj.read()
262
+
263
+ expected = f.read()
264
+
265
+ assert len(obj.stream) == len(expected)
266
+ assert obj.stream == expected
267
+
268
+
245
269
  def test_create_text_default_filled(template_stream, pdf_samples, request):
246
270
  expected_path = os.path.join(
247
271
  pdf_samples, "widget", "create_text_default_filled.pdf"
File without changes
File without changes
File without changes
File without changes
File without changes