PyPDFForm 3.0.0__py3-none-any.whl → 3.0.1__py3-none-any.whl
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.
- PyPDFForm/__init__.py +1 -1
- PyPDFForm/constants.py +1 -1
- PyPDFForm/utils.py +10 -16
- {pypdfform-3.0.0.dist-info → pypdfform-3.0.1.dist-info}/METADATA +1 -1
- {pypdfform-3.0.0.dist-info → pypdfform-3.0.1.dist-info}/RECORD +8 -8
- {pypdfform-3.0.0.dist-info → pypdfform-3.0.1.dist-info}/WHEEL +0 -0
- {pypdfform-3.0.0.dist-info → pypdfform-3.0.1.dist-info}/licenses/LICENSE +0 -0
- {pypdfform-3.0.0.dist-info → pypdfform-3.0.1.dist-info}/top_level.txt +0 -0
PyPDFForm/__init__.py
CHANGED
|
@@ -20,7 +20,7 @@ The library supports various PDF form features, including:
|
|
|
20
20
|
PyPDFForm aims to simplify PDF form manipulation, making it accessible to developers of all skill levels.
|
|
21
21
|
"""
|
|
22
22
|
|
|
23
|
-
__version__ = "3.0.
|
|
23
|
+
__version__ = "3.0.1"
|
|
24
24
|
|
|
25
25
|
from .middleware.text import Text # exposing for setting global font attrs
|
|
26
26
|
from .wrapper import PdfWrapper
|
PyPDFForm/constants.py
CHANGED
PyPDFForm/utils.py
CHANGED
|
@@ -21,11 +21,9 @@ from string import ascii_letters, digits, punctuation
|
|
|
21
21
|
from typing import Any, BinaryIO, List, Union
|
|
22
22
|
|
|
23
23
|
from pypdf import PdfReader, PdfWriter
|
|
24
|
-
from pypdf.generic import
|
|
25
|
-
NameObject)
|
|
24
|
+
from pypdf.generic import ArrayObject, DictionaryObject, NameObject
|
|
26
25
|
|
|
27
|
-
from .constants import
|
|
28
|
-
NeedAppearances, Root)
|
|
26
|
+
from .constants import UNIQUE_SUFFIX_LENGTH, XFA, AcroForm, Annots, Root
|
|
29
27
|
|
|
30
28
|
|
|
31
29
|
@lru_cache
|
|
@@ -57,9 +55,10 @@ def enable_adobe_mode(pdf: bytes) -> bytes:
|
|
|
57
55
|
"""Enables Adobe-specific settings in the PDF to ensure proper rendering of form fields.
|
|
58
56
|
|
|
59
57
|
This function modifies the PDF's AcroForm dictionary to include the `NeedAppearances` flag,
|
|
60
|
-
which forces Adobe Reader to generate appearance streams for form fields.
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
which forces Adobe Reader to generate appearance streams for form fields. It also handles
|
|
59
|
+
XFA (XML Forms Architecture) forms by removing the XFA entry from the AcroForm dictionary
|
|
60
|
+
if it exists, ensuring compatibility and proper rendering. This ensures that the form fields
|
|
61
|
+
are rendered correctly in Adobe Reader, especially when the form is filled programmatically.
|
|
63
62
|
|
|
64
63
|
Args:
|
|
65
64
|
pdf (bytes): The PDF content as bytes.
|
|
@@ -70,16 +69,11 @@ def enable_adobe_mode(pdf: bytes) -> bytes:
|
|
|
70
69
|
reader = PdfReader(stream_to_io(pdf))
|
|
71
70
|
writer = PdfWriter()
|
|
72
71
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return pdf
|
|
77
|
-
else:
|
|
78
|
-
reader.trailer[Root].update({NameObject(AcroForm): DictionaryObject()})
|
|
79
|
-
reader.trailer[Root][AcroForm].update(
|
|
80
|
-
{NameObject(NeedAppearances): BooleanObject(True)}
|
|
81
|
-
)
|
|
72
|
+
if AcroForm in reader.trailer[Root] and XFA in reader.trailer[Root][AcroForm]:
|
|
73
|
+
del reader.trailer[Root][AcroForm][XFA]
|
|
74
|
+
|
|
82
75
|
writer.append(reader)
|
|
76
|
+
writer.set_need_appearances_writer()
|
|
83
77
|
|
|
84
78
|
with BytesIO() as f:
|
|
85
79
|
writer.write(f)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
PyPDFForm/__init__.py,sha256=
|
|
1
|
+
PyPDFForm/__init__.py,sha256=fU6FXBvP7HiJDQK5BgFx4eTbgpGsOH9hZ6Xwf02-L_I,925
|
|
2
2
|
PyPDFForm/adapter.py,sha256=8E_PZlXU1ALWez_pWF_U52cynzowK_NQFYzMJoH9VUk,2428
|
|
3
|
-
PyPDFForm/constants.py,sha256=
|
|
3
|
+
PyPDFForm/constants.py,sha256=WQjBvYTryj5gxxeXECPgHplXXXmqHNeVbgmhvlLDCpA,2443
|
|
4
4
|
PyPDFForm/coordinate.py,sha256=VMVkqa-VAGJSGVvetZwOxeMzIgQtQdvtn_DI_qSecCE,3876
|
|
5
5
|
PyPDFForm/filler.py,sha256=YgYYUKyG4n6ADmE7vjlorbqDVbhU3LEJn1H3Ptl26CA,7233
|
|
6
6
|
PyPDFForm/font.py,sha256=EZSAHnkzaBo96p9XJrQDMcEhjh5BZ8p7WwFC3SbKRMM,8828
|
|
@@ -8,7 +8,7 @@ PyPDFForm/hooks.py,sha256=myL6RS82uz4oM3mufOgFuyfMWkhhUwNNgWYLkMUuUtk,9016
|
|
|
8
8
|
PyPDFForm/image.py,sha256=CAC69jEfSbWbyNJcjLhjWVSNJuFh7frMI70eaiFayHw,3823
|
|
9
9
|
PyPDFForm/patterns.py,sha256=pv2a5aJD3xv9pJddtOu_Ol7A6p0VWlDcnHyW1diqeIM,7151
|
|
10
10
|
PyPDFForm/template.py,sha256=aGhwezcynmwCEck1SUNlQvgfupn-plV9mV2FF2RNn_M,9188
|
|
11
|
-
PyPDFForm/utils.py,sha256=
|
|
11
|
+
PyPDFForm/utils.py,sha256=RX2mOP2uCIcN_JcTalCdYKhnYtyYc8dUIqg1wP_7MJA,10867
|
|
12
12
|
PyPDFForm/watermark.py,sha256=9p1tjaIqicXngTNai_iOEkCoXRYnR66azB4s7wNsZUw,9349
|
|
13
13
|
PyPDFForm/wrapper.py,sha256=Ysd1mkvE5OfDkjUI6mNFIt16-JUKwj2ifbp1MioWPUo,25257
|
|
14
14
|
PyPDFForm/middleware/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -28,8 +28,8 @@ PyPDFForm/widgets/image.py,sha256=aSD-3MEZFIRL7HYVuO6Os8irfSUOLHA_rHGkqcEIPPA,85
|
|
|
28
28
|
PyPDFForm/widgets/radio.py,sha256=nWSQQp06kRISO7Q7FVFeB3PXYvMOSc0SMhRs1bHTxeQ,2261
|
|
29
29
|
PyPDFForm/widgets/signature.py,sha256=EqIRIuKSQEg8LJZ_Mu859eEvs0dwO-mzkMNuhHG1Vsg,4034
|
|
30
30
|
PyPDFForm/widgets/text.py,sha256=gtheE6_w0vQPRJJ9oj_l9FaMDEGnPtvVR6_axsrmxKI,1540
|
|
31
|
-
pypdfform-3.0.
|
|
32
|
-
pypdfform-3.0.
|
|
33
|
-
pypdfform-3.0.
|
|
34
|
-
pypdfform-3.0.
|
|
35
|
-
pypdfform-3.0.
|
|
31
|
+
pypdfform-3.0.1.dist-info/licenses/LICENSE,sha256=43awmYkI6opyTpg19me731iO1WfXZwViqb67oWtCsFY,1065
|
|
32
|
+
pypdfform-3.0.1.dist-info/METADATA,sha256=AU8iGNQzMZynQLF-7jeMio5xJg4jjHLXYWqsaxuJ59I,4587
|
|
33
|
+
pypdfform-3.0.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
34
|
+
pypdfform-3.0.1.dist-info/top_level.txt,sha256=GQQKuWqPUjT9YZqwK95NlAQzxjwoQrsxQ8ureM8lWOY,10
|
|
35
|
+
pypdfform-3.0.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|