python-pdffiller 1.0.0__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.
@@ -0,0 +1,52 @@
1
+ """
2
+ Module representing a checkbox widget.
3
+
4
+ This module defines the Checkbox class, which is a subclass of the
5
+ Widget class. It represents a checkbox form field in a PDF document.
6
+ """
7
+
8
+ from typing import Any, Dict, List, Optional
9
+
10
+ from .base import Widget
11
+
12
+
13
+ class CheckBoxWidget(Widget):
14
+ """
15
+ Represents a checkbox widget.
16
+
17
+ The Checkbox class provides a concrete implementation for
18
+ checkbox form fields. It inherits from the Widget class and
19
+ implements the schema_definition and sample_value properties.
20
+ """
21
+
22
+ def __init__(
23
+ self,
24
+ name: str,
25
+ page_number: int,
26
+ value: Optional[str] = None,
27
+ choices: Optional[List[str]] = None,
28
+ ) -> None:
29
+ """
30
+ Initializes a checkbox widget.
31
+
32
+ Args:
33
+ name (str): The name of the checkbox.
34
+ page_number (int): The associated page index
35
+ value (str): The initial value of the checkbox. Defaults to None.
36
+ choices: The list of available choices. Defaults to None.
37
+ """
38
+ super().__init__(name, page_number, value)
39
+ self.choices: Optional[List[str]] = choices
40
+
41
+ @property
42
+ def schema_definition(self) -> Dict[str, Any]:
43
+ """
44
+ Returns the schema definition for the checkbox.
45
+
46
+ The schema definition is a dictionary that describes the
47
+ data type and other constraints for the checkbox value.
48
+
49
+ Returns:
50
+ dict: A dictionary representing the schema definition.
51
+ """
52
+ return {"FieldType": "checkbox", "FieldOptions": self.choices, **super().schema_definition}
@@ -0,0 +1,37 @@
1
+ """
2
+ Module representing a radio button widget.
3
+
4
+ This module defines the Radio class, which is a subclass of the
5
+ Checkbox class. It represents a radio button form field in a PDF
6
+ document, allowing users to select one option from a group of choices.
7
+ """
8
+
9
+ from typing import Any, Dict
10
+
11
+ from .checkbox import CheckBoxWidget
12
+
13
+
14
+ class RadioWidget(CheckBoxWidget):
15
+ """
16
+ Represents a radio button widget.
17
+
18
+ The Radio class provides a concrete implementation for radio button
19
+ form fields. It inherits from the Checkbox class and implements
20
+ the schema_definition and sample_value properties.
21
+ """
22
+
23
+ @property
24
+ def schema_definition(self) -> Dict[str, Any]:
25
+ """
26
+ Returns the schema definition for the checkbox.
27
+
28
+ The schema definition is a dictionary that describes the
29
+ data type and other constraints for the checkbox value.
30
+
31
+ Returns:
32
+ dict: A dictionary representing the schema definition.
33
+ """
34
+ return {
35
+ **super().schema_definition,
36
+ "FieldType": "radio",
37
+ }
@@ -0,0 +1,82 @@
1
+ """
2
+ Module representing a text field widget.
3
+
4
+ This module defines the Text class, which is a subclass of the
5
+ Widget class. It represents a text field form field in a PDF document,
6
+ allowing users to enter text.
7
+ """
8
+
9
+ from typing import Any, Dict, Optional
10
+
11
+ from .base import Widget
12
+
13
+
14
+ class TextWidget(Widget):
15
+ """
16
+ Represents a text field widget.
17
+
18
+ The Text class provides a concrete implementation for text field
19
+ form fields. It inherits from the Widget class and implements
20
+ the value, schema_definition.
21
+ """
22
+
23
+ def __init__(
24
+ self,
25
+ name: str,
26
+ page_number: int,
27
+ value: Optional[str] = None,
28
+ max_length: Optional[int] = None,
29
+ ) -> None:
30
+ """
31
+ Initializes a text widget.
32
+
33
+ Args:
34
+ name (str): The name of the checkbox.
35
+ page_number (int): The associated page index
36
+ value (str): The initial value of the checkbox. Defaults to None.
37
+ max_length (int): The maximum length of the text field. Defaults to None.
38
+ """
39
+ super().__init__(name, page_number, value)
40
+ self.max_length: Optional[int] = max_length
41
+
42
+ @property
43
+ def value(self) -> str:
44
+ """
45
+ Returns the value of the text field.
46
+
47
+ If the value is an integer or float, it is converted to a string.
48
+
49
+ Returns:
50
+ str: The value of the text field.
51
+ """
52
+ if isinstance(self._value, (int, float)):
53
+ return str(self._value)
54
+
55
+ return self._value or ""
56
+
57
+ @value.setter
58
+ def value(self, value: Optional[str]) -> None:
59
+ """
60
+ Sets the value of the text field.
61
+
62
+ Args:
63
+ value (str): The value to set.
64
+ """
65
+ self._value = value
66
+
67
+ @property
68
+ def schema_definition(self) -> Dict[str, Any]:
69
+ """
70
+ Returns the schema definition for the checkbox.
71
+
72
+ The schema definition is a dictionary that describes the
73
+ data type and other constraints for the checkbox value.
74
+
75
+ Returns:
76
+ dict: A dictionary representing the schema definition.
77
+ """
78
+ schema: Dict[str, Any] = {"FieldType": "text", **super().schema_definition}
79
+ if self.max_length:
80
+ schema["MaxLength"] = self.max_length
81
+
82
+ return schema
@@ -0,0 +1,138 @@
1
+ Metadata-Version: 2.4
2
+ Name: python-pdffiller
3
+ Version: 1.0.0
4
+ Summary: Interact with PDF by inspecting or filling it
5
+ Author-email: Jacques Raphanel <jraphanel@sismic.fr>
6
+ License-Expression: MIT
7
+ Project-URL: changelog, https://github.com/sismicfr/pypdffiller/blob/main/CHANGELOG.md
8
+ Project-URL: homepage, https://github.com/sismicfr/pypdffiller
9
+ Project-URL: issues, https://github.com/sismicfr/pypdffiller/issues
10
+ Project-URL: repository, http://github.com/sismicfr/pypdffiller.git
11
+ Keywords: development,pdf
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Natural Language :: English
16
+ Classifier: Operating System :: POSIX
17
+ Classifier: Operating System :: Microsoft :: Windows
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Programming Language :: Python :: 3.14
25
+ Requires-Python: >=3.9
26
+ Description-Content-Type: text/x-rst
27
+ License-File: COPYING
28
+ License-File: AUTHORS.rst
29
+ Requires-Dist: pypdf
30
+ Requires-Dist: colorama
31
+ Requires-Dist: pyyaml
32
+ Dynamic: license-file
33
+
34
+ pypdffiller
35
+ ===========
36
+
37
+ |Test| |PyPI| |Python| |Code Style| |Pre-Commit| |License|
38
+
39
+ ``pypdffiller`` is a free and open source pure-Python 3 library for PDF form processing. It contains the essential
40
+ functionalities needed to interact with PDF forms:
41
+
42
+ - Inspect what data a PDF form needs to be filled with.
43
+ - Fill a PDF form by simply creating a Python dictionary.
44
+
45
+ Installation
46
+ ------------
47
+
48
+ As of first version, ``pypdffiller`` is compatible with Python 3.9+.
49
+
50
+ Use ``pip`` to install the latest stable version of ``pypdffiller``:
51
+
52
+ .. code-block:: console
53
+
54
+ $ pip install --upgrade python-pdffiller
55
+
56
+ The current development version is available on both `GitHub.com
57
+ <https://github.com/sismicfr/pypdffiller>`__ and can be
58
+ installed directly from the git repository:
59
+
60
+ .. code-block:: console
61
+
62
+ $ pip install git+https://github.com/sismicfr/pypdffiller.git
63
+
64
+
65
+ Bug reports
66
+ -----------
67
+
68
+ Please report bugs and feature requests at
69
+ https://github.com/sismicfr/pypdffiller/issues.
70
+
71
+
72
+ Documentation
73
+ -------------
74
+
75
+ The full documentation for CLI and API is available at https://pypdffiller.readthedocs.org/en/stable/.
76
+
77
+ Build the docs
78
+ ~~~~~~~~~~~~~~
79
+
80
+ We use ``tox`` to manage our environment and build the documentation:
81
+
82
+ .. code-block:: console
83
+
84
+ $ pip install tox
85
+ $ tox -e docs
86
+
87
+ Executable
88
+ ----------
89
+
90
+ In addition to the **Python** package, a standalone executable can be built using **PyInstaller**.
91
+
92
+ Build the executable
93
+ ~~~~~~~~~~~~~~~~~~~~
94
+
95
+ We use ``tox`` to manage our environment and build the executable:
96
+
97
+ .. code-block:: console
98
+
99
+ $ pip install tox
100
+ $ tox -e installer
101
+
102
+ .. code-block:: console
103
+
104
+ $ make exe
105
+
106
+ Contributing
107
+ ------------
108
+
109
+ For guidelines for contributing to ``pypdffiller``, refer to `CONTRIBUTING.rst <https://github.com/sismicfr/pypdffiller/blob/main/CONTRIBUTING.rst>`_.
110
+
111
+
112
+ .. |Test| image:: https://github.com/sismicfr/pypdffiller/workflows/Test/badge.svg
113
+ :target: https://github.com/sismicfr/pypdffiller/actions
114
+ :alt: Test
115
+
116
+ .. |PyPI| image:: https://img.shields.io/pypi/v/pypdffiller?label=PyPI&logo=pypi
117
+ :target: https://badge.fury.io/py/pypdffiller
118
+ :alt: PyPI
119
+
120
+ .. |Read the Docs| image:: https://img.shields.io/readthedocs/pypdffiller?label=Documentation&logo=Read%20the%20Docs
121
+ :target: https://sismicfr.github.io/pypdffiller
122
+ :alt: Docs
123
+
124
+ .. |Python| image:: https://img.shields.io/pypi/pyversions/pypdffiller.svg?label=Python&logo=Python
125
+ :target: https://pypi.python.org/pypi/pypdffiller
126
+ :alt: Python
127
+
128
+ .. |Code Style| image:: https://img.shields.io/badge/code%20style-black-000000.svg?label=Code%20Style
129
+ :target: https://github.com/python/black
130
+ :alt: Code Style
131
+
132
+ .. |Pre-Commit| image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&label=Pre-Commit
133
+ :target: https://github.com/pre-commit/pre-commit
134
+ :alt: Pre-Commit
135
+
136
+ .. |License| image:: https://img.shields.io/github/license/sismicfr/pypdffiller?label=License
137
+ :target: https://github.com/sismicfr/pypdffiller/blob/main/COPYING
138
+ :alt: License
@@ -0,0 +1,36 @@
1
+ pdffiller/__init__.py,sha256=0HtgXhEV1fKTKAcOXGcq4UsCFflDIPCDQvckshZf-1k,195
2
+ pdffiller/__main__.py,sha256=7NPQgZVx6VSZS7OrmyJQ_O1vL4wiSqhiILi-outwUqM,107
3
+ pdffiller/_version.py,sha256=dVVZYByHt776RZ19IpKaGRcRJNNDSwzljM3Y1DafozI,172
4
+ pdffiller/const.py,sha256=if_j5I8ftczpjrzZjA7idv-XpvIj1-XBF4oe6VtQvF0,434
5
+ pdffiller/exceptions.py,sha256=CdN93bZ0mBBS5vLxg14FYZUy4xkYqoD3_SzqtSkZr4g,1624
6
+ pdffiller/pdf.py,sha256=AfsPcDWoar0N7nRImzpJcgUQ3TyeI8yBZfIv1FYA2Rk,18534
7
+ pdffiller/py.typed.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ pdffiller/typing.py,sha256=suxFXOGIF07R8UhrEf-ro_vNA2pXJGfe8CX64dStXTs,954
9
+ pdffiller/utils.py,sha256=pmGf3QwkhKwosk_eFCauzHM-XHp_WGVQAtZlxa7taYY,827
10
+ pdffiller/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
+ pdffiller/cli/args.py,sha256=1MUtxIVgdBWJCjgp2gxUuGW-vH4qne92A7Rns2DylsQ,870
12
+ pdffiller/cli/boolean_action.py,sha256=8Fcd_OuffMWch87CP-TEIQJEDZAh2zJk1gGeBpzTgQw,1294
13
+ pdffiller/cli/cli.py,sha256=ZHGQK6rd3mYzXvSRxAa1PvZgNA6v9pwJCEVtLmOpzPs,9665
14
+ pdffiller/cli/command.py,sha256=9WdP3OywCDRCOv2uyw_mTXIXWIzVoIfsRbkZOh5tnqA,9747
15
+ pdffiller/cli/exit_codes.py,sha256=zjCx3km09qTpooCjRl3RhDJWRWr_WKZKeWFPzcHojko,442
16
+ pdffiller/cli/formatters.py,sha256=k0Y0FaRuHFlW8pxePxGsYA7UEmG-gLkb_H3rFbyTuV4,405
17
+ pdffiller/cli/once_argument.py,sha256=olQvNhObObS0iXVL1YCa-_lH76SV0I4FvnlgR9roqo4,687
18
+ pdffiller/cli/smart_formatter.py,sha256=59hwF07nKbp-P9IfbqKgMFsfbvjIw5SACCZpUF4nnuE,318
19
+ pdffiller/cli/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
+ pdffiller/cli/commands/dump_data_fields.py,sha256=YR8aENCGkCRro0jTuuvMg2HCEos9aF81aL4SxP--_2E,2262
21
+ pdffiller/cli/commands/fill_form.py,sha256=QylVT7cSMbH5FjdNqOtU_eVL9tWQjCceroZ7A2152Q0,4668
22
+ pdffiller/io/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
+ pdffiller/io/colors.py,sha256=QCBEWksTVNurOJQYO0zh1X_xxIOXxXmYSJhbCqnNjI8,1710
24
+ pdffiller/io/output.py,sha256=NWV1SabnR_kXmR8tfUKQQoQ_3RV9wqiSnHqzinQDgB0,11217
25
+ pdffiller/widgets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
+ pdffiller/widgets/base.py,sha256=HosjtNWOXRVjCidZZYlWN7Y_M9Ft1P-F4G3EyluUI3I,2901
27
+ pdffiller/widgets/checkbox.py,sha256=6kBSN7sc6uzujAFzfC_HO8SvtiK736ym7hdPBIR1eT4,1603
28
+ pdffiller/widgets/radio.py,sha256=Db9Oc3Q8ge8qqTVPLoz3I1_SJBGyJ8KfA33ixZMr78c,1070
29
+ pdffiller/widgets/text.py,sha256=JsluVKl7ZNj5_UZI9rL4MSOd6rLiPxSggHH3g9raUJI,2289
30
+ python_pdffiller-1.0.0.dist-info/licenses/AUTHORS.rst,sha256=1_hVzMKgmoXvGgrcZC7sIbU_6PvvkB6vwqevAqzrIkQ,205
31
+ python_pdffiller-1.0.0.dist-info/licenses/COPYING,sha256=ADPe-bH2wYq8nFf6EPJyovzTJyl3jSPnm09mGI8FSTo,1074
32
+ python_pdffiller-1.0.0.dist-info/METADATA,sha256=JxmTx9WQJxJWNfvpaMAhpRsJqr1pomUlSuCWmvIXSd4,4319
33
+ python_pdffiller-1.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
34
+ python_pdffiller-1.0.0.dist-info/entry_points.txt,sha256=RESKKpPPdWl0wDET96ntuFoUydALx9j0mxtbt-MEBjU,49
35
+ python_pdffiller-1.0.0.dist-info/top_level.txt,sha256=5MGWCBFYlu_Ax-I5PgQkV9Xw7O48maPe9z8Qj_yVPL4,10
36
+ python_pdffiller-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ pdffiller = pdffiller.cli:main
@@ -0,0 +1,7 @@
1
+ Contributors
2
+ ------------
3
+
4
+ |contributors|
5
+
6
+ .. |contributors| image:: https://contributors-img.web.app/image?repo=sismicfr/pypdffiller
7
+ :target: https://github.com/sismicfr/pypdffiller/graphs/contributors
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 SISMIC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1 @@
1
+ pdffiller