Skip to content

PDFCLOUD-6575 Add PDF page box updates - #61

Draft
datalogics-tsmith wants to merge 6 commits into
pdfcloud-6573-add-tdm-reservation-policy-supportfrom
pdfcloud-6575-add-pdf-page-box-updates
Draft

datalogics-tsmith wants to merge 6 commits into
pdfcloud-6573-add-tdm-reservation-policy-supportfrom
pdfcloud-6575-add-pdf-page-box-updates

Conversation

@datalogics-tsmith

Copy link
Copy Markdown
Contributor

PDFCLOUD-6575

Why this change

The Python SDK does not currently provide a typed way to update PDF page boundary boxes. Callers would otherwise need to reproduce the service's nested JSON-string payload, page-selection rules, and different MediaBox versus inset-box margin requirements themselves.

This draft is stacked on #60, which is itself based on #57 and #58. Those pull requests should merge before this one is made ready for final review.

What changed

This adds public discriminated input types for MediaBox, CropBox, BleedBox, TrimBox, and ArtBox updates. A Pydantic payload model validates and serializes those definitions, while thin synchronous and asynchronous client helpers delegate request execution through the existing file-operation path.

The implementation keeps signed MediaBox margins separate from strictly positive inset-box margins. It also models page selection symbolically so overlapping selections for the same box type can be rejected before transport without preventing different box types from targeting the same page.

Behavior changes

Callers can now pass an uploaded PDF and typed page-box definitions to set_pdf_page_boxes. Supported selections include positive page numbers, ascending ranges, ranges ending in last, and the all, even, and odd selectors.

Invalid ranges use the service's concise error wording. Non-finite margins, non-positive inset margins, unsupported resources, and overlapping selections for the same box are rejected locally. MediaBox margins remain signed so pages can be enlarged.

This is an additive API change and does not intentionally break existing callers.

Validation

The Python 3.10-3.14 Nox matrix passed with 3,397 tests and 10 expected skips on each interpreter. Total coverage was 96%, and the client-class function coverage gate remained above 90%.

The endpoint-specific unit module passed 106 tests. The live module passed 26 tests through both clients, asserting exact geometry for all five box types, page-number/range/even/odd targeting, the positive inset boundary, and service rejection of invalid, descending, and overlapping selections.

Ruff, basedpyright, changed-file pre-commit hooks, strict documentation builds, package builds, and the standalone live example also passed. The complete live-service catalog and complete examples matrix were not rerun because validation was focused on this endpoint and example.

Risks and follow-ups

The current test service accepts zero and negative inset margins when local validation is bypassed with a raw body override, despite the published contract requiring values greater than zero. The SDK follows the published contract and rejects those values locally; service-side enforcement remains a follow-up.

After #57, #58, and #60 merge, this pull request should be updated onto main and reviewed again for conflicts introduced by the stacked changes.

- Add typed MediaBox and inset page-box definitions for selected pages.
- Validate finite margins, ascending ranges, and overlapping selections.
- Serialize uploaded PDF IDs and box definitions for the service contract.

Assisted-by: Codex
- Add synchronous and asynchronous helpers for uploaded PDF resources.
- Accept typed box definitions, output names, and request customization.
- Delegate payload validation and serialization to the page-box model.

Assisted-by: Codex
- Verify exact payload serialization and every supported page selector.
- Exercise sync and async calls, customization, and response mapping.
- Reject invalid margins, resources, ranges, and overlapping selections.

Assisted-by: Codex
- Exercise every page-box type through synchronous and async clients.
- Assert exact geometry, selector targeting, and positive boundaries.
- Verify service rejection of invalid, descending, and overlapping input.

Assisted-by: Codex
- Add a standalone upload example using typed MediaBox and CropBox input.
- Print generated PDF metadata so users and CI can confirm success.
- List the page-box workflow in the runnable example inventory.

Assisted-by: Codex
- Link the page geometry helper from the cleanup and normalization guide.
- List typed MediaBox, CropBox, BleedBox, TrimBox, and ArtBox support.

Assisted-by: Codex

This branch was previously deployed

1 inactive deployment
ci-live — 0775e035 Deployed Nov 4, 2026 by datalogics-tsmith via Examples (Python 3.14) #605
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant