pdfdancer-client-python 0.2.15__py3-none-any.whl → 0.2.16__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 pdfdancer-client-python might be problematic. Click here for more details.

@@ -0,0 +1,190 @@
1
+ Metadata-Version: 2.4
2
+ Name: pdfdancer-client-python
3
+ Version: 0.2.16
4
+ Summary: Python client for PDFDancer API
5
+ Author-email: "The Famous Cat Ltd." <hi@thefamouscat.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://www.pdfdancer.com/
8
+ Project-URL: Repository, https://github.com/MenschMachine/pdfdancer-client-python
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Requires-Python: >=3.10
17
+ Description-Content-Type: text/markdown
18
+ Requires-Dist: requests>=2.25.0
19
+ Requires-Dist: pydantic>=1.8.0
20
+ Requires-Dist: typing-extensions>=4.0.0
21
+ Requires-Dist: python-dotenv>=0.19.0
22
+ Provides-Extra: dev
23
+ Requires-Dist: pytest>=7.0; extra == "dev"
24
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
25
+ Requires-Dist: pytest-mock>=3.10.0; extra == "dev"
26
+ Requires-Dist: black>=22.0; extra == "dev"
27
+ Requires-Dist: flake8>=5.0; extra == "dev"
28
+ Requires-Dist: mypy>=1.0; extra == "dev"
29
+ Requires-Dist: isort>=5.10.0; extra == "dev"
30
+ Requires-Dist: build>=0.8.0; extra == "dev"
31
+ Requires-Dist: twine>=4.0.0; extra == "dev"
32
+
33
+ # PDFDancer Python Client
34
+
35
+ **Getting Started with PDFDancer**
36
+
37
+ PDFDancer gives you pixel-perfect programmatic control over any PDF document from Python. Locate existing elements by
38
+ coordinates or text, adjust them precisely, add brand-new content, and ship the modified PDF in memory or on disk. The
39
+ same API is also available for TypeScript and Java, so teams can orchestrate identical PDF workflows across stacks.
40
+
41
+ > Need the raw API schema? The latest OpenAPI description lives in `docs/openapi.yml` and is published at
42
+ > https://bucket.pdfdancer.com/api-doc/development-0.0.yml.
43
+
44
+ ## Highlights
45
+
46
+ - Locate paragraphs, text lines, images, vector paths, form fields, and pages by index, coordinates, or text prefixes.
47
+ - Edit existing content in place with fluent editors and context managers that apply changes safely.
48
+ - Programmatically control third-party PDFs—modify invoices, contracts, and reports you did not author.
49
+ - Add content with precise XY positioning using paragraph and image builders, custom fonts, and color helpers.
50
+ - Export results as bytes for downstream processing or save directly to disk with one call.
51
+
52
+ ## What Makes PDFDancer Different
53
+
54
+ - **Edit any PDF**: Work with documents from customers, governments, or vendors—not just ones you generated.
55
+ - **Pixel-perfect positioning**: Move or add elements at exact coordinates and keep the original layout intact.
56
+ - **Surgical text replacement**: Swap or rewrite paragraphs without reflowing the rest of the page.
57
+ - **Form manipulation**: Inspect, fill, and update AcroForm fields programmatically.
58
+ - **Coordinate-based selection**: Select objects by position, bounding box, or text patterns.
59
+ - **Real PDF editing**: Modify the underlying PDF structure instead of merely stamping overlays.
60
+
61
+ ## Installation
62
+
63
+ ```bash
64
+ pip install pdfdancer-client-python
65
+
66
+ # Editable install for local development
67
+ pip install -e .
68
+ ```
69
+
70
+ Requires Python 3.10+ and a PDFDancer API token.
71
+
72
+ ## Quick Start — Edit an Existing PDF
73
+
74
+ ```python
75
+ from pathlib import Path
76
+ from pdfdancer import Color, PDFDancer, StandardFonts
77
+
78
+ with PDFDancer.open(
79
+ pdf_data=Path("input.pdf"),
80
+ token="your-api-token", # optional when PDFDANCER_TOKEN is set
81
+ base_url="https://api.pdfdancer.com",
82
+ ) as pdf:
83
+ # Locate and update an existing paragraph
84
+ heading = pdf.page(0).select_paragraphs_starting_with("Executive Summary")[0]
85
+ heading.move_to(72, 680)
86
+ with heading.edit() as editor:
87
+ editor.replace("Overview")
88
+
89
+ # Add a new paragraph with precise placement
90
+ pdf.new_paragraph() \
91
+ .text("Generated with PDFDancer") \
92
+ .font(StandardFonts.HELVETICA, 12) \
93
+ .color(Color(70, 70, 70)) \
94
+ .line_spacing(1.4) \
95
+ .at(page_index=0, x=72, y=520) \
96
+ .add()
97
+
98
+ # Persist the modified document
99
+ pdf.save("output.pdf")
100
+ # or keep it in memory
101
+ pdf_bytes = pdf.get_bytes()
102
+ ```
103
+
104
+ ## Create a Blank PDF
105
+
106
+ ```python
107
+ from pathlib import Path
108
+ from pdfdancer import Color, PDFDancer, StandardFonts
109
+
110
+ with PDFDancer.new(token="your-api-token") as pdf:
111
+ pdf.new_paragraph() \
112
+ .text("Quarterly Summary") \
113
+ .font(StandardFonts.TIMES_BOLD, 18) \
114
+ .color(Color(10, 10, 80)) \
115
+ .line_spacing(1.2) \
116
+ .at(page_index=0, x=72, y=730) \
117
+ .add()
118
+
119
+ pdf.new_image() \
120
+ .from_file(Path("logo.png")) \
121
+ .at(page=0, x=420, y=710) \
122
+ .add()
123
+
124
+ pdf.save("summary.pdf")
125
+ ```
126
+
127
+ ## Work with Forms and Layout
128
+
129
+ ```python
130
+ from pdfdancer import PDFDancer
131
+
132
+ with PDFDancer.open("contract.pdf") as pdf:
133
+ # Inspect global document structure
134
+ pages = pdf.pages()
135
+ print("Total pages:", len(pages))
136
+
137
+ # Update form fields
138
+ signature = pdf.select_form_fields_by_name("signature")[0]
139
+ signature.edit().value("Signed by Jane Doe").apply()
140
+
141
+ # Trim or move content at specific coordinates
142
+ images = pdf.page(1).select_images()
143
+ for image in images:
144
+ x = image.position.x()
145
+ if x is not None and x < 100:
146
+ image.delete()
147
+ ```
148
+
149
+ Selectors return typed objects (`ParagraphObject`, `TextLineObject`, `ImageObject`, `FormFieldObject`, `PageClient`, …)
150
+ with helpers such as `delete()`, `move_to(x, y)`, or `edit()` depending on the object type.
151
+
152
+ ## Configuration
153
+
154
+ - Set `PDFDANCER_TOKEN` for authentication (preferred for local development and CI).
155
+ - Override the API host with `PDFDANCER_BASE_URL` (e.g., sandbox environments).
156
+ - Tune HTTP read timeouts via the `timeout` argument on `PDFDancer.open()` and `PDFDancer.new()`.
157
+
158
+ ## Error Handling
159
+
160
+ Operations raise subclasses of `PdfDancerException`:
161
+
162
+ - `ValidationException`: input validation problems (missing token, invalid coordinates, etc.).
163
+ - `FontNotFoundException`: requested font unavailable on the service.
164
+ - `HttpClientException`: transport or server errors with detailed context.
165
+ - `SessionException`: session creation and lifecycle failures.
166
+
167
+ Wrap automated workflows in `try/except` blocks to surface actionable errors to your users.
168
+
169
+ ## Development
170
+
171
+ ```bash
172
+ python -m venv venv
173
+ source venv/bin/activate # Windows: venv\Scripts\activate
174
+ pip install -e ".[dev]"
175
+
176
+ pytest -q # unit suite
177
+ pytest tests/e2e # integration tests (requires live API + fixtures)
178
+ python -m build # produce distribution artifacts
179
+ ```
180
+
181
+ Releases are published with `python release.py`. Contributions are welcome via pull request.
182
+
183
+ ## Related SDKs
184
+
185
+ - TypeScript client: https://github.com/MenschMachine/pdfdancer-client-js
186
+ - Java client: https://github.com/MenschMachine/pdfdancer-client-java
187
+
188
+ ## License
189
+
190
+ MIT © The Famous Cat Ltd.
@@ -5,7 +5,7 @@ pdfdancer/models.py,sha256=Tw77OWjELD4sfDqnCwmhczrKClwyLan9gXTqsvgoJxE,24765
5
5
  pdfdancer/paragraph_builder.py,sha256=pgFTkyhYrx4VQDKy4Vhp-042OMlJOD8D0MW9flkvC7Y,9410
6
6
  pdfdancer/pdfdancer_v1.py,sha256=BbVMNVmjlCESZ0jlWuDmFby90LUv6Y3qJcLLPJCIloc,54487
7
7
  pdfdancer/types.py,sha256=vG9kTryS6fHmJYGqH31bkq3gG4zF-9DpHqCFkpybuV8,12471
8
- pdfdancer_client_python-0.2.15.dist-info/METADATA,sha256=thyX7c8YmcOBwbu8j9GumfVUUJqMkPx_qcHXdeVz99o,7060
9
- pdfdancer_client_python-0.2.15.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
10
- pdfdancer_client_python-0.2.15.dist-info/top_level.txt,sha256=ICwSVRpcCKrdBF9QlaX9Y0e_N3Nk1p7QVxadGOnbxeY,10
11
- pdfdancer_client_python-0.2.15.dist-info/RECORD,,
8
+ pdfdancer_client_python-0.2.16.dist-info/METADATA,sha256=VELMMZEB27JXJWYZe2rLi6ck9sZ_q_MwPNYhuJngMZU,6911
9
+ pdfdancer_client_python-0.2.16.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
10
+ pdfdancer_client_python-0.2.16.dist-info/top_level.txt,sha256=ICwSVRpcCKrdBF9QlaX9Y0e_N3Nk1p7QVxadGOnbxeY,10
11
+ pdfdancer_client_python-0.2.16.dist-info/RECORD,,
@@ -1,200 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: pdfdancer-client-python
3
- Version: 0.2.15
4
- Summary: Python client for PDFDancer API
5
- Author-email: "The Famous Cat Ltd." <hi@thefamouscat.com>
6
- License: MIT
7
- Project-URL: Homepage, https://www.pdfdancer.com/
8
- Project-URL: Repository, https://github.com/MenschMachine/pdfdancer-client-python
9
- Classifier: Development Status :: 4 - Beta
10
- Classifier: Intended Audience :: Developers
11
- Classifier: License :: OSI Approved :: MIT License
12
- Classifier: Programming Language :: Python :: 3.10
13
- Classifier: Programming Language :: Python :: 3.11
14
- Classifier: Programming Language :: Python :: 3.12
15
- Classifier: Programming Language :: Python :: 3.13
16
- Requires-Python: >=3.10
17
- Description-Content-Type: text/markdown
18
- Requires-Dist: requests>=2.25.0
19
- Requires-Dist: pydantic>=1.8.0
20
- Requires-Dist: typing-extensions>=4.0.0
21
- Requires-Dist: python-dotenv>=0.19.0
22
- Provides-Extra: dev
23
- Requires-Dist: pytest>=7.0; extra == "dev"
24
- Requires-Dist: pytest-cov>=4.0; extra == "dev"
25
- Requires-Dist: pytest-mock>=3.10.0; extra == "dev"
26
- Requires-Dist: black>=22.0; extra == "dev"
27
- Requires-Dist: flake8>=5.0; extra == "dev"
28
- Requires-Dist: mypy>=1.0; extra == "dev"
29
- Requires-Dist: isort>=5.10.0; extra == "dev"
30
- Requires-Dist: build>=0.8.0; extra == "dev"
31
- Requires-Dist: twine>=4.0.0; extra == "dev"
32
-
33
- # PDFDancer Python Client
34
-
35
- Automate PDF clean-up, redaction, form filling, and content injection against the PDFDancer API from Python. The client
36
- gives you page-scoped selectors, fluent editors, and builders so you can read, modify, and export PDFs programmatically
37
- in just a few lines.
38
-
39
- Latest schema version available at https://bucket.pdfdancer.com/api-doc/development-0.0.yml.
40
-
41
- ## Highlights
42
-
43
- - Locate anything inside a PDF—paragraphs, text lines, images, vector paths, pages, AcroForm fields—by page,
44
- coordinates, or text prefixes
45
- - Edit or delete existing content with fluent paragraph/text editors and safe apply-on-exit context managers
46
- - Fill or update form fields and propagate the changes back to the document instantly
47
- - Add brand-new content with paragraph/image builders, custom fonts, and precise page positioning
48
- - Download results as bytes for downstream processing or save directly to disk with one method call
49
-
50
- ## Core Capabilities
51
-
52
- - Clean up layout by moving or deleting paragraphs, text lines, or shapes on specific pages
53
- - Search and filter content (e.g., paragraphs starting with "Invoice") to drive custom workflows
54
- - Redact or replace text in bulk with chained editor operations
55
- - Populate AcroForms for contract generation or onboarding flows
56
- - Insert logos, signatures, and generated paragraphs at deterministic coordinates
57
- - Export modified PDFs as bytes for APIs, S3 uploads, or direct file saves
58
-
59
- ## Requirements
60
-
61
- - Python 3.10 or newer
62
- - A PDFDancer API token (set `PDFDANCER_TOKEN` or pass `token=...`)
63
- - Network access to a PDFDancer service (defaults to `https://api.pdfdancer.com`; override with `PDFDANCER_BASE_URL`)
64
-
65
- ## Installation
66
-
67
- ```bash
68
- pip install pdfdancer-client-python
69
-
70
- # Editable install for local development
71
- pip install -e .
72
- ```
73
-
74
- ## Getting Started
75
-
76
- ```python
77
- from pathlib import Path
78
- from pdfdancer import Color, PDFDancer
79
-
80
- with PDFDancer.open(
81
- pdf_data=Path("input.pdf"),
82
- token="your-api-token", # optional when PDFDANCER_TOKEN is set
83
- base_url="https://api.pdfdancer.com",
84
- ) as pdf:
85
- # Locate existing content
86
- heading = pdf.page(0).select_paragraphs_starting_with("Executive Summary")[0]
87
- heading.edit().replace("Overview").apply()
88
-
89
- # Add a new paragraph using the fluent builder
90
- pdf.new_paragraph()
91
- .text("Generated with PDFDancer")
92
- .font("Helvetica", 12)
93
- .color(Color(70, 70, 70))
94
- .line_spacing(1.4)
95
- .at(page_index=0, x=72, y=520)
96
- .add()
97
-
98
- # Persist the modified document
99
- pdf.save("output.pdf")
100
- ```
101
-
102
- ### Authentication Tips
103
-
104
- - Prefer setting `PDFDANCER_TOKEN` in your environment for local development.
105
- - Override the API host by setting `PDFDANCER_BASE_URL` or passing `base_url="https://sandbox.pdfdancer.com"`.
106
- - Use the `timeout` parameter on `PDFDancer.open()` to adjust HTTP read timeouts.
107
-
108
- ## Selecting PDF Content
109
-
110
- ```python
111
- with PDFDancer.open("report.pdf") as pdf: # environment variables provide token/URL
112
- all_paragraphs = pdf.select_paragraphs()
113
- page_zero_images = pdf.page(0).select_images()
114
- form_fields = pdf.page(2).select_form_fields()
115
- paths_at_cursor = pdf.page(3).select_paths_at(x=150, y=320)
116
-
117
- page = pdf.page(0).get()
118
- print(page.internal_id, page.position.bounding_rect)
119
- ```
120
-
121
- Selectors return rich objects (`ParagraphObject`, `TextLineObject`, `ImageObject`, `FormFieldObject`, etc.) with helpers
122
- such as `delete()`, `move_to(x, y)`, or `edit()` depending on the object type.
123
-
124
- ## Editing Text and Forms
125
-
126
- ```python
127
- with PDFDancer.open("report.pdf") as pdf:
128
- paragraph = pdf.page(0).select_paragraphs_starting_with("Disclaimer")[0]
129
-
130
- # Chain updates explicitly…
131
- paragraph.edit()
132
- .replace("Updated disclaimer text")
133
- .font("Roboto-Regular", 11)
134
- .line_spacing(1.1)
135
- .move_to(72, 140)
136
- .apply()
137
-
138
- # …or use the context manager to auto-apply on success
139
- with paragraph.edit() as edit:
140
- edit.replace("Context-managed update").color(Color(120, 0, 0))
141
-
142
- # Update an AcroForm field
143
- field = pdf.page(1).select_form_fields_by_name("signature")[0]
144
- field.edit().value("Signed by Jane Doe").apply()
145
- ```
146
-
147
- ## Adding New Content
148
-
149
- ```python
150
- with PDFDancer.open("report.pdf") as pdf:
151
- # Register fonts from the service
152
- fonts = pdf.find_fonts("Roboto", 12)
153
- pdf.register_font("/path/to/custom.ttf")
154
-
155
- # Paragraphs
156
- pdf.new_paragraph()
157
- .text("Greetings from PDFDancer!")
158
- .font(fonts[0].name, fonts[0].size)
159
- .at(page_index=0, x=220, y=480)
160
- .add()
161
-
162
- # Raster images
163
- pdf.new_image()
164
- .from_file(Path("logo.png"))
165
- .at(page=0, x=48, y=700)
166
- .add()
167
- ```
168
-
169
- ## Downloading Results
170
-
171
- - `pdf.get_pdf_file()` returns the modified PDF as `bytes` (ideal for storage services or HTTP responses).
172
- - `pdf.save("output.pdf")` writes directly to disk, creating directories when needed.
173
-
174
- ## Error Handling
175
-
176
- Most operations raise subclasses of `PdfDancerException`:
177
-
178
- - `ValidationException` for client-side validation issues (missing token, invalid coordinates, etc.).
179
- - `FontNotFoundException` when the service cannot locate a requested font.
180
- - `HttpClientException` for transport or server errors with detailed messages.
181
- - `SessionException` when session creation fails.
182
-
183
- Wrap complex workflows in `try/except` blocks to surface actionable errors to your users.
184
-
185
- ## Local Development
186
-
187
- ```bash
188
- python -m venv venv
189
- source venv/bin/activate # Windows: venv\Scripts\activate
190
- pip install -e ".[dev]"
191
-
192
- pytest -q # run the fast unit suite
193
- pytest tests/e2e # integration tests (requires live API + fixtures)
194
- ```
195
-
196
- Package builds are handled by `python -m build`, and release artifacts are published via `python release.py`.
197
-
198
- ## License
199
-
200
- MIT © The Famous Cat Ltd.