Skip to content

Commit 83a9dbe

Browse files
authored
fixes issues so that we pass integration tests (#30)
1 parent 1d26358 commit 83a9dbe

File tree

11 files changed

+425
-188
lines changed

11 files changed

+425
-188
lines changed

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ result = self._http_client.post("/build", files=files, json_data=instructions)
6868
```
6969

7070
### Key Learnings from split_pdf Implementation
71-
- **Page Ranges**: Use `{"start": 0, "end": 5}` (0-based, end exclusive) and `{"start": 10}` (to end)
71+
- **Page Ranges**: Use `{"start": 0, "end": 4}` (0-based, end inclusive) and `{"start": 10}` (to end)
7272
- **Multiple Operations**: Some tools require multiple API calls (one per page range/operation)
7373
- **Error Handling**: API returns 400 with detailed errors when parameters are invalid
7474
- **Testing Strategy**: Focus on integration tests with live API rather than unit test mocking

PR_CONTENT.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ This PR adds 8 new direct API methods that were missing from the Python client,
77

88
### 1. Create Redactions (3 methods for different strategies)
99
- `create_redactions_preset()` - Use built-in patterns for common sensitive data
10-
- Presets: social-security-number, credit-card-number, email, phone-number, date, currency
10+
- Presets: social-security-number, credit-card-number, email-address, international-phone-number, north-american-phone-number, date, time, us-zip-code
1111
- `create_redactions_regex()` - Custom regex patterns for flexible redaction
1212
- `create_redactions_text()` - Exact text matches with case sensitivity options
1313

1414
### 2. PDF Optimization
1515
- `optimize_pdf()` - Reduce file size with multiple optimization options:
1616
- Grayscale conversion (text, graphics, images)
17-
- Image quality reduction (1-100)
17+
- Image optimization quality (1-4, where 4 is most optimized)
1818
- Linearization for web viewing
1919
- Option to disable images entirely
2020

@@ -82,7 +82,7 @@ client.apply_redactions("redacted.pdf", output_path="final.pdf")
8282
client.optimize_pdf(
8383
"large_document.pdf",
8484
grayscale_images=True,
85-
reduce_image_quality=50,
85+
image_optimization_quality=4,
8686
linearize=True,
8787
output_path="optimized.pdf"
8888
)
@@ -123,4 +123,4 @@ No migration needed - existing code continues to work as before.
123123
After merging:
124124
1. Update README with examples of new methods
125125
2. Consider adding more tools: HTML to PDF, digital signatures, etc.
126-
3. Create a cookbook/examples directory with common use cases
126+
3. Create a cookbook/examples directory with common use cases

SUPPORTED_OPERATIONS.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -171,16 +171,16 @@ Splits a PDF into multiple documents by page ranges.
171171
parts = client.split_pdf(
172172
"document.pdf",
173173
page_ranges=[
174-
{"start": 0, "end": 5}, # Pages 1-5
175-
{"start": 5, "end": 10}, # Pages 6-10
174+
{"start": 0, "end": 4}, # Pages 1-5
175+
{"start": 5, "end": 9}, # Pages 6-10
176176
{"start": 10} # Pages 11 to end
177177
]
178178
)
179179

180180
# Save to specific files
181181
client.split_pdf(
182182
"document.pdf",
183-
page_ranges=[{"start": 0, "end": 2}, {"start": 2}],
183+
page_ranges=[{"start": 0, "end": 1}, {"start": 2}],
184184
output_paths=["part1.pdf", "part2.pdf"]
185185
)
186186

@@ -264,7 +264,7 @@ Sets custom labels/numbering for specific page ranges in a PDF.
264264
- `labels`: List of label configurations. Each dict must contain:
265265
- `pages`: Page range dict with `start` (required) and optionally `end`
266266
- `label`: String label to apply to those pages
267-
- Page ranges use 0-based indexing where `end` is exclusive.
267+
- Page ranges use 0-based indexing where `end` is inclusive.
268268
- `output_path`: Optional path to save the output file
269269

270270
**Returns:**
@@ -276,8 +276,8 @@ Sets custom labels/numbering for specific page ranges in a PDF.
276276
client.set_page_label(
277277
"document.pdf",
278278
labels=[
279-
{"pages": {"start": 0, "end": 3}, "label": "Introduction"},
280-
{"pages": {"start": 3, "end": 10}, "label": "Chapter 1"},
279+
{"pages": {"start": 0, "end": 2}, "label": "Introduction"},
280+
{"pages": {"start": 3, "end": 9}, "label": "Chapter 1"},
281281
{"pages": {"start": 10}, "label": "Appendix"}
282282
],
283283
output_path="labeled_document.pdf"
@@ -286,7 +286,7 @@ client.set_page_label(
286286
# Set label for single page
287287
client.set_page_label(
288288
"document.pdf",
289-
labels=[{"pages": {"start": 0, "end": 1}, "label": "Cover Page"}]
289+
labels=[{"pages": {"start": 0, "end": 0}, "label": "Cover Page"}]
290290
)
291291
```
292292

@@ -318,7 +318,7 @@ client.build(input_file="report.docx") \
318318
client.build(input_file="document.pdf") \
319319
.add_step("rotate-pages", {"degrees": 90}) \
320320
.set_page_labels([
321-
{"pages": {"start": 0, "end": 3}, "label": "Introduction"},
321+
{"pages": {"start": 0, "end": 2}, "label": "Introduction"},
322322
{"pages": {"start": 3}, "label": "Content"}
323323
]) \
324324
.execute(output_path="labeled_document.pdf")
@@ -383,4 +383,4 @@ Common exceptions:
383383
- `APIError` - General API errors with status code
384384
- `ValidationError` - Invalid parameters
385385
- `FileNotFoundError` - File not found
386-
- `ValueError` - Invalid input values
386+
- `ValueError` - Invalid input values

0 commit comments

Comments
 (0)