PyPDFForm 5.4.0__tar.gz → 5.4.1__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.
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PKG-INFO +1 -1
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/__init__.py +1 -1
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/constants.py +0 -1
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/egress.py +7 -11
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/filler.py +2 -4
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/font.py +1 -3
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/hooks.py +2 -4
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/template.py +1 -3
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/utils.py +2 -4
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/watermark.py +2 -5
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm.egg-info/PKG-INFO +1 -1
- {pypdfform-5.4.0 → pypdfform-5.4.1}/LICENSE +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/cli/__init__.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/cli/common.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/cli/create.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/cli/entry.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/cli/inspect.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/cli/remove.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/cli/root.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/cli/schemas/__init__.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/cli/schemas/create.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/cli/schemas/update.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/cli/update.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/__init__.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/adapter.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/annotations/__init__.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/annotations/base.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/annotations/link.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/annotations/stamp.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/annotations/text.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/annotations/text_markup.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/assets/__init__.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/assets/bedrock.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/assets/blank.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/coordinate.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/deprecation.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/image.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/middleware/__init__.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/middleware/base.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/middleware/checkbox.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/middleware/dropdown.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/middleware/image.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/middleware/radio.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/middleware/signature.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/middleware/text.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/patterns.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/raw/__init__.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/raw/circle.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/raw/ellipse.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/raw/image.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/raw/line.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/raw/rect.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/raw/text.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/types.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/widgets/__init__.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/widgets/base.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/widgets/checkbox.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/widgets/dropdown.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/widgets/image.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/widgets/radio.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/widgets/signature.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/widgets/text.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm/lib/wrapper.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm.egg-info/SOURCES.txt +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm.egg-info/dependency_links.txt +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm.egg-info/entry_points.txt +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm.egg-info/requires.txt +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/PyPDFForm.egg-info/top_level.txt +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/README.md +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/pyproject.toml +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/setup.cfg +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/tests/test_bulk_create_fields.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/tests/test_create_widget.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/tests/test_draw_elements.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/tests/test_dropdown.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/tests/test_extract_middleware_attributes.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/tests/test_fill_max_length_text_field.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/tests/test_font_widths.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/tests/test_functional.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/tests/test_generate_appearance_streams.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/tests/test_js.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/tests/test_need_appearances.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/tests/test_paragraph.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/tests/test_signature.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/tests/test_use_full_widget_name.py +0 -0
- {pypdfform-5.4.0 → pypdfform-5.4.1}/tests/test_widget_attr_trigger.py +0 -0
|
@@ -17,7 +17,7 @@ from io import BytesIO
|
|
|
17
17
|
from warnings import catch_warnings, filterwarnings
|
|
18
18
|
|
|
19
19
|
from pikepdf import Pdf
|
|
20
|
-
from pypdf import
|
|
20
|
+
from pypdf import PdfWriter
|
|
21
21
|
from pypdf.generic import ArrayObject, DictionaryObject, NameObject, TextStringObject
|
|
22
22
|
|
|
23
23
|
from .constants import (
|
|
@@ -29,7 +29,6 @@ from .constants import (
|
|
|
29
29
|
JavaScript,
|
|
30
30
|
OpenAction,
|
|
31
31
|
Parent,
|
|
32
|
-
Root,
|
|
33
32
|
S,
|
|
34
33
|
Title,
|
|
35
34
|
)
|
|
@@ -58,13 +57,12 @@ def appearance_streams_handler(pdf: bytes, generate_appearance_streams: bool) ->
|
|
|
58
57
|
Returns:
|
|
59
58
|
bytes: The modified PDF content as a bytes stream.
|
|
60
59
|
"""
|
|
61
|
-
|
|
62
|
-
writer = PdfWriter()
|
|
60
|
+
writer = PdfWriter(BytesIO(pdf))
|
|
63
61
|
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
root_object = writer._root_object # type: ignore # noqa: SLF001 # # pylint: disable=W0212
|
|
63
|
+
if AcroForm in root_object and XFA in root_object[AcroForm]:
|
|
64
|
+
del root_object[AcroForm][XFA]
|
|
66
65
|
|
|
67
|
-
writer.append(reader)
|
|
68
66
|
writer.set_need_appearances_writer()
|
|
69
67
|
|
|
70
68
|
with BytesIO() as f:
|
|
@@ -107,12 +105,10 @@ def preserve_pdf_properties(
|
|
|
107
105
|
Returns:
|
|
108
106
|
bytes: The modified PDF content as a bytes stream.
|
|
109
107
|
"""
|
|
110
|
-
|
|
111
|
-
writer = PdfWriter()
|
|
112
|
-
writer.append(reader)
|
|
108
|
+
writer = PdfWriter(BytesIO(pdf))
|
|
113
109
|
|
|
114
110
|
if title or metadata:
|
|
115
|
-
_metadata =
|
|
111
|
+
_metadata = writer.metadata or {}
|
|
116
112
|
if metadata:
|
|
117
113
|
_metadata.update(metadata)
|
|
118
114
|
if title:
|
|
@@ -11,7 +11,7 @@ supports flattening the filled form to prevent further modifications.
|
|
|
11
11
|
from io import BytesIO
|
|
12
12
|
from typing import Dict, cast
|
|
13
13
|
|
|
14
|
-
from pypdf import
|
|
14
|
+
from pypdf import PdfWriter
|
|
15
15
|
from pypdf.generic import DictionaryObject
|
|
16
16
|
|
|
17
17
|
from .constants import Annots
|
|
@@ -188,9 +188,7 @@ def fill(
|
|
|
188
188
|
stream as bytes when an image or signature was drawn. The second
|
|
189
189
|
tuple item is None when no image drawing is needed.
|
|
190
190
|
"""
|
|
191
|
-
|
|
192
|
-
out = PdfWriter()
|
|
193
|
-
out.append(pdf)
|
|
191
|
+
out = PdfWriter(BytesIO(template))
|
|
194
192
|
|
|
195
193
|
radio_button_tracker = {}
|
|
196
194
|
images_to_draw = {}
|
|
@@ -276,9 +276,7 @@ def register_font_acroform(
|
|
|
276
276
|
(str) that was assigned to the registered font within the PDF.
|
|
277
277
|
"""
|
|
278
278
|
base_font_name = _get_base_font_name(ttf_stream)
|
|
279
|
-
|
|
280
|
-
writer = PdfWriter()
|
|
281
|
-
writer.append(reader)
|
|
279
|
+
writer = PdfWriter(BytesIO(pdf))
|
|
282
280
|
|
|
283
281
|
font_descriptor_params = {}
|
|
284
282
|
font_dict_params = {}
|
|
@@ -13,7 +13,7 @@ import sys
|
|
|
13
13
|
from io import BytesIO
|
|
14
14
|
from typing import TextIO, cast
|
|
15
15
|
|
|
16
|
-
from pypdf import
|
|
16
|
+
from pypdf import PdfWriter
|
|
17
17
|
from pypdf.generic import (
|
|
18
18
|
ArrayObject,
|
|
19
19
|
DictionaryObject,
|
|
@@ -84,9 +84,7 @@ def trigger_widget_hooks(
|
|
|
84
84
|
Returns:
|
|
85
85
|
bytes: The modified PDF data as bytes, with the widget hooks applied.
|
|
86
86
|
"""
|
|
87
|
-
|
|
88
|
-
output = PdfWriter()
|
|
89
|
-
output.append(pdf_file)
|
|
87
|
+
output = PdfWriter(BytesIO(pdf))
|
|
90
88
|
|
|
91
89
|
for page in output.pages:
|
|
92
90
|
for annot in page.get(Annots, []):
|
|
@@ -496,9 +496,7 @@ def update_widget_keys(
|
|
|
496
496
|
Returns:
|
|
497
497
|
bytes: The updated PDF template as a byte stream.
|
|
498
498
|
"""
|
|
499
|
-
|
|
500
|
-
out = PdfWriter()
|
|
501
|
-
out.append(pdf)
|
|
499
|
+
out = PdfWriter(BytesIO(template))
|
|
502
500
|
|
|
503
501
|
_apply_widget_key_updates(out, widgets, old_keys, new_keys, indices)
|
|
504
502
|
|
|
@@ -46,13 +46,11 @@ def remove_all_widgets(pdf: bytes) -> bytes:
|
|
|
46
46
|
Returns:
|
|
47
47
|
bytes: The PDF with all widgets removed, as a bytes stream.
|
|
48
48
|
"""
|
|
49
|
-
pdf_file = PdfReader(BytesIO(pdf))
|
|
50
49
|
result_stream = BytesIO()
|
|
51
|
-
writer = PdfWriter()
|
|
52
|
-
for page in
|
|
50
|
+
writer = PdfWriter(BytesIO(pdf))
|
|
51
|
+
for page in writer.pages:
|
|
53
52
|
if page.annotations:
|
|
54
53
|
page.annotations.clear()
|
|
55
|
-
writer.add_page(page)
|
|
56
54
|
|
|
57
55
|
writer.write(result_stream)
|
|
58
56
|
result_stream.seek(0)
|
|
@@ -326,9 +326,7 @@ def merge_watermarks_with_pdf(
|
|
|
326
326
|
bytes: A byte stream representing the merged PDF with watermarks applied.
|
|
327
327
|
"""
|
|
328
328
|
result = BytesIO()
|
|
329
|
-
|
|
330
|
-
output = PdfWriter()
|
|
331
|
-
output.append(pdf_file)
|
|
329
|
+
output = PdfWriter(BytesIO(pdf))
|
|
332
330
|
|
|
333
331
|
for i, page in enumerate(output.pages):
|
|
334
332
|
if watermarks[i]:
|
|
@@ -546,8 +544,7 @@ def copy_watermark_widgets(
|
|
|
546
544
|
Returns:
|
|
547
545
|
bytes: The modified PDF byte stream with copied widgets.
|
|
548
546
|
"""
|
|
549
|
-
pdf_writer = PdfWriter()
|
|
550
|
-
pdf_writer.append(PdfReader(BytesIO(pdf)))
|
|
547
|
+
pdf_writer = PdfWriter(BytesIO(pdf))
|
|
551
548
|
|
|
552
549
|
widgets_to_copy = _collect_widgets_to_copy(pdf_writer, watermarks, keys, page_num)
|
|
553
550
|
_apply_widgets_to_pages(pdf_writer, widgets_to_copy)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|