PyPDFForm 1.5.3__tar.gz → 1.5.4__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 (50) hide show
  1. {pypdfform-1.5.3 → pypdfform-1.5.4}/PKG-INFO +1 -1
  2. {pypdfform-1.5.3 → pypdfform-1.5.4}/PyPDFForm/__init__.py +1 -1
  3. pypdfform-1.5.4/PyPDFForm/middleware/image.py +10 -0
  4. {pypdfform-1.5.3 → pypdfform-1.5.4}/PyPDFForm/middleware/radio.py +1 -10
  5. {pypdfform-1.5.3 → pypdfform-1.5.4}/PyPDFForm/middleware/signature.py +2 -2
  6. {pypdfform-1.5.3 → pypdfform-1.5.4}/PyPDFForm/wrapper.py +6 -3
  7. {pypdfform-1.5.3 → pypdfform-1.5.4}/PyPDFForm.egg-info/PKG-INFO +1 -1
  8. {pypdfform-1.5.3 → pypdfform-1.5.4}/tests/test_functional_simple.py +30 -1
  9. pypdfform-1.5.3/PyPDFForm/middleware/image.py +0 -21
  10. {pypdfform-1.5.3 → pypdfform-1.5.4}/LICENSE +0 -0
  11. {pypdfform-1.5.3 → pypdfform-1.5.4}/PyPDFForm/adapter.py +0 -0
  12. {pypdfform-1.5.3 → pypdfform-1.5.4}/PyPDFForm/constants.py +0 -0
  13. {pypdfform-1.5.3 → pypdfform-1.5.4}/PyPDFForm/coordinate.py +0 -0
  14. {pypdfform-1.5.3 → pypdfform-1.5.4}/PyPDFForm/filler.py +0 -0
  15. {pypdfform-1.5.3 → pypdfform-1.5.4}/PyPDFForm/font.py +0 -0
  16. {pypdfform-1.5.3 → pypdfform-1.5.4}/PyPDFForm/image.py +0 -0
  17. {pypdfform-1.5.3 → pypdfform-1.5.4}/PyPDFForm/middleware/__init__.py +0 -0
  18. {pypdfform-1.5.3 → pypdfform-1.5.4}/PyPDFForm/middleware/base.py +0 -0
  19. {pypdfform-1.5.3 → pypdfform-1.5.4}/PyPDFForm/middleware/checkbox.py +0 -0
  20. {pypdfform-1.5.3 → pypdfform-1.5.4}/PyPDFForm/middleware/dropdown.py +0 -0
  21. {pypdfform-1.5.3 → pypdfform-1.5.4}/PyPDFForm/middleware/text.py +0 -0
  22. {pypdfform-1.5.3 → pypdfform-1.5.4}/PyPDFForm/patterns.py +0 -0
  23. {pypdfform-1.5.3 → pypdfform-1.5.4}/PyPDFForm/template.py +0 -0
  24. {pypdfform-1.5.3 → pypdfform-1.5.4}/PyPDFForm/utils.py +0 -0
  25. {pypdfform-1.5.3 → pypdfform-1.5.4}/PyPDFForm/watermark.py +0 -0
  26. {pypdfform-1.5.3 → pypdfform-1.5.4}/PyPDFForm/widgets/__init__.py +0 -0
  27. {pypdfform-1.5.3 → pypdfform-1.5.4}/PyPDFForm/widgets/base.py +0 -0
  28. {pypdfform-1.5.3 → pypdfform-1.5.4}/PyPDFForm/widgets/checkbox.py +0 -0
  29. {pypdfform-1.5.3 → pypdfform-1.5.4}/PyPDFForm/widgets/dropdown.py +0 -0
  30. {pypdfform-1.5.3 → pypdfform-1.5.4}/PyPDFForm/widgets/text.py +0 -0
  31. {pypdfform-1.5.3 → pypdfform-1.5.4}/PyPDFForm.egg-info/SOURCES.txt +0 -0
  32. {pypdfform-1.5.3 → pypdfform-1.5.4}/PyPDFForm.egg-info/dependency_links.txt +0 -0
  33. {pypdfform-1.5.3 → pypdfform-1.5.4}/PyPDFForm.egg-info/requires.txt +0 -0
  34. {pypdfform-1.5.3 → pypdfform-1.5.4}/PyPDFForm.egg-info/top_level.txt +0 -0
  35. {pypdfform-1.5.3 → pypdfform-1.5.4}/README.md +0 -0
  36. {pypdfform-1.5.3 → pypdfform-1.5.4}/setup.cfg +0 -0
  37. {pypdfform-1.5.3 → pypdfform-1.5.4}/setup.py +0 -0
  38. {pypdfform-1.5.3 → pypdfform-1.5.4}/tests/test_adobe_mode.py +0 -0
  39. {pypdfform-1.5.3 → pypdfform-1.5.4}/tests/test_create_widget.py +0 -0
  40. {pypdfform-1.5.3 → pypdfform-1.5.4}/tests/test_dropdown.py +0 -0
  41. {pypdfform-1.5.3 → pypdfform-1.5.4}/tests/test_dropdown_simple.py +0 -0
  42. {pypdfform-1.5.3 → pypdfform-1.5.4}/tests/test_fill_max_length_text_field.py +0 -0
  43. {pypdfform-1.5.3 → pypdfform-1.5.4}/tests/test_fill_max_length_text_field_simple.py +0 -0
  44. {pypdfform-1.5.3 → pypdfform-1.5.4}/tests/test_fill_method.py +0 -0
  45. {pypdfform-1.5.3 → pypdfform-1.5.4}/tests/test_functional.py +0 -0
  46. {pypdfform-1.5.3 → pypdfform-1.5.4}/tests/test_paragraph.py +0 -0
  47. {pypdfform-1.5.3 → pypdfform-1.5.4}/tests/test_paragraph_simple.py +0 -0
  48. {pypdfform-1.5.3 → pypdfform-1.5.4}/tests/test_preview.py +0 -0
  49. {pypdfform-1.5.3 → pypdfform-1.5.4}/tests/test_signature.py +0 -0
  50. {pypdfform-1.5.3 → pypdfform-1.5.4}/tests/test_use_full_widget_name.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: PyPDFForm
3
- Version: 1.5.3
3
+ Version: 1.5.4
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.5.3"
4
+ __version__ = "1.5.4"
5
5
 
6
6
  from .wrapper import FormWrapper, PdfWrapper
7
7
 
@@ -0,0 +1,10 @@
1
+ # -*- coding: utf-8 -*-
2
+ """Contains image field middleware."""
3
+
4
+ from .signature import Signature
5
+
6
+
7
+ class Image(Signature):
8
+ """A class to represent an image field widget."""
9
+
10
+ preserve_aspect_ratio = False
@@ -7,16 +7,7 @@ from .checkbox import Checkbox
7
7
  class Radio(Checkbox):
8
8
  """A class to represent a radiobutton widget."""
9
9
 
10
- def __init__(
11
- self,
12
- name: str,
13
- value: int = None,
14
- ) -> None:
15
- """Constructs all attributes for the radiobutton."""
16
-
17
- super().__init__(name, value)
18
-
19
- self.number_of_options = 0
10
+ number_of_options = 0
20
11
 
21
12
  @property
22
13
  def schema_definition(self) -> dict:
@@ -11,6 +11,8 @@ from .base import Widget
11
11
  class Signature(Widget):
12
12
  """A class to represent a signature field widget."""
13
13
 
14
+ preserve_aspect_ratio = True
15
+
14
16
  def __init__(
15
17
  self,
16
18
  name: str,
@@ -20,8 +22,6 @@ class Signature(Widget):
20
22
 
21
23
  super().__init__(name, value)
22
24
 
23
- self.preserve_aspect_ratio = True
24
-
25
25
  @property
26
26
  def schema_definition(self) -> dict:
27
27
  """Json schema definition of the signature field."""
@@ -166,10 +166,13 @@ class PdfWrapper(FormWrapper):
166
166
  if not other.stream:
167
167
  return self
168
168
 
169
- new_obj = self.__class__()
170
- new_obj.stream = merge_two_pdfs(self.stream, other.stream)
169
+ for k in self.widgets:
170
+ if k in other.widgets:
171
+ other.update_widget_key(k, f"{k}-{id(other)}", defer=True)
171
172
 
172
- return new_obj
173
+ other.commit_widget_key_updates()
174
+
175
+ return self.__class__(merge_two_pdfs(self.stream, other.stream))
173
176
 
174
177
  @property
175
178
  def preview(self) -> bytes:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: PyPDFForm
3
- Version: 1.5.3
3
+ Version: 1.5.4
4
4
  Summary: The Python library for PDF forms.
5
5
  Home-page: https://github.com/chinapandaman/PyPDFForm
6
6
  Author: Jinge Li
@@ -2,7 +2,9 @@
2
2
 
3
3
  import os
4
4
 
5
- from PyPDFForm import FormWrapper
5
+ from PyPDFForm import FormWrapper, PdfWrapper
6
+ from PyPDFForm.constants import T, V
7
+ from PyPDFForm.template import get_widgets_by_page
6
8
 
7
9
 
8
10
  def test_fill(template_stream, pdf_samples, data_dict, request):
@@ -151,3 +153,30 @@ def test_undo_checkbox(pdf_samples, request):
151
153
 
152
154
  assert len(obj.stream) == len(expected)
153
155
  assert obj.stream == expected
156
+
157
+
158
+ def test_add_object_id(template_stream):
159
+ result = PdfWrapper()
160
+ ids = []
161
+
162
+ for i in range(5):
163
+ obj = PdfWrapper(
164
+ FormWrapper(template_stream).fill({"test": f"value-{i}"}).read()
165
+ )
166
+ result += obj
167
+ ids.append(id(obj))
168
+
169
+ merged = PdfWrapper(result.read())
170
+
171
+ for each in ids[1:]:
172
+ assert f"test-{each}" in merged.widgets
173
+
174
+ for page, widgets in get_widgets_by_page(result.read()).items():
175
+ for widget in widgets:
176
+ assert widget[T] in merged.widgets
177
+ if widget[T] == "test":
178
+ assert widget[V] == "value-0"
179
+ elif V in widget and "value-" in widget[V]:
180
+ assert widget[V] == f"value-{page // 3}"
181
+ assert widget[T].split("-")[0] == "test"
182
+ assert int(widget[T].split("-")[1]) in ids[1:]
@@ -1,21 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """Contains image field middleware."""
3
-
4
- from typing import BinaryIO, Union
5
-
6
- from .signature import Signature
7
-
8
-
9
- class Image(Signature):
10
- """A class to represent an image field widget."""
11
-
12
- def __init__(
13
- self,
14
- name: str,
15
- value: Union[bytes, str, BinaryIO] = None,
16
- ) -> None:
17
- """Constructs all attributes for the image field."""
18
-
19
- super().__init__(name, value)
20
-
21
- self.preserve_aspect_ratio = False
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes