Skip to content

PDFCLOUD-6243: Add PDF shape overlays - #45

Merged
datalogics-kam merged 10 commits into
mainfrom
pdfcloud-6243-pdf-with-added-shapes
Oct 8, 2026
Merged

datalogics-kam merged 10 commits into
mainfrom
pdfcloud-6243-pdf-with-added-shapes

Conversation

@datalogics-kam

Copy link
Copy Markdown
Contributor

PDFCLOUD-6243

Why this change

The Python SDK did not expose the documented /pdf-with-added-shapes operation, forcing callers to build raw requests for line and rectangle overlays. This adds a typed, validated SDK workflow that matches the service contract.

What changed (high level)

The clients now provide synchronous and asynchronous add_shapes_to_pdf helpers backed by Pydantic request models and public shape type contracts. The implementation keeps uploaded-file lifecycle handling consistent with existing helpers and serializes shape objects into the API JSON layout.

Behavior changes

Callers can add one or more lines or rectangles to an uploaded PDF, including RGB or CMYK colors, opacity, stroke width, output naming, and optional accessibility tagging. Local validation rejects invalid coordinates, conflicting color modes, non-PDF inputs, empty shape lists, and tagging metadata without tag_enabled=True.

Validation

  • uv run pytest --ignore tests/live -n auto --maxschedchunk 2 — 1,001 passed.
  • PDFREST_LIVE_BASE_URL=http://sleipnir:3000/ uv run pytest tests/live/test_live_add_shapes_to_pdf.py -n auto --maxschedchunk 2 — 4 passed.
  • Ruff, BasedPyright, and the client class-function coverage gate passed.
  • The Python 3.11 nox session passed with live tests excluded. The full matrix remains limited by the local Python 3.10 nox virtualenv symlink loop.

Risks and follow-ups

This is a stacked draft PR on #44: merge #44 first, then this PR. The PR base is pdfcloud-6233-new-pdfrest-api-skill, so reviewers see only the endpoint-support layer. No breaking changes are intended.

@datalogics-kam
datalogics-kam force-pushed the pdfcloud-6243-pdf-with-added-shapes branch from 847f705 to ed495f3 Compare August 23, 2026 00:39
@datalogics-kam
datalogics-kam force-pushed the pdfcloud-6243-pdf-with-added-shapes branch from ed495f3 to c13e6a3 Compare August 23, 2026 13:39
@datalogics-kam
datalogics-kam marked this pull request as ready for review September 8, 2026 19:23
@datalogics-kam
datalogics-kam changed the base branch from pdfcloud-6233-new-pdfrest-api-skill to main September 8, 2026 19:35
@datalogics-tsmith

Copy link
Copy Markdown
Contributor

Codex had some feedback:

Confirm the locally imposed numeric bounds against the service.
_internal.py (line 1837) requires nonnegative coordinates, positive dimensions/stroke widths, and bounded colors/opacity. The live suite only verifies rejection of page=0. In particular, the public API documentation does not clearly establish that negative coordinates are invalid, so the SDK may be stricter than the server. Please add live boundary cases for every constraint through both transports.

Exercise every public structure-type value.
PdfContentStructureType (line 146) publishes a large Literal contract, but the tests use only "Figure". Repository policy requires every accepted spelling through sync and async unit/live tests, plus a server-rejected invalid value. Otherwise, the SDK could advertise values the server does not accept.

Document the public literal alias as required.
PdfContentStructureType should use an explicit TypeAlias assignment followed immediately by the required PEP 258 docstring, including an Accepted values: list with the meaning of every value.

@datalogics-kam

Copy link
Copy Markdown
Contributor Author

In the future, please ask Codex to make a changes-requested review on the PR, assigning the findings to code lines. It can do that if you have gh installed. It's a lot more convenient.

@datalogics-tsmith datalogics-tsmith left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks—the core implementation and current live happy/error paths work, but I’m requesting changes because the published SDK contract is not fully established and documented. Please address the three inline comments: verify numeric bounds against the service with complete boundary parity, exhaustively validate the public structure-type Literal through both transports and live tests, and document the alias per repository policy.

Comment thread src/pdfrest/models/_internal.py
Comment thread tests/live/test_live_add_shapes_to_pdf.py
Comment thread src/pdfrest/types/public.py Outdated
@netlify

netlify Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for pdfrest-python ready!

Name Link
🔨 Latest commit d9abf38
🔍 Latest deploy log https://app.netlify.com/projects/pdfrest-python/deploys/6ac7da968be5450008728d7d
😎 Deploy Preview https://deploy-preview-45--pdfrest-python.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@datalogics-cgreen datalogics-cgreen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll allow it. 🧐

@datalogics-gwalczak datalogics-gwalczak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manager approval.

- Add sync and async shape helpers with typed line and rectangle inputs
- Validate shape coordinates, colors, tagging, and PDF resources
- Cover JSON serialization, live service behavior, and API guide discovery

Assisted-by: Codex
- Resolve MkDocs cross-references for added shape object types
- Restore strict documentation build validation

Assisted-by: Codex
- Assert async timeout propagation and PDF MIME validation
- Reject multiple input PDFs through both client transports
- Cover shape geometry, opacity, and color range boundaries

Assisted-by: Codex
- Accept one RGB or CMYK color field for each shape color
- Route colors to pdfRest's RGB or CMYK wire fields by channel count
- Update unit and live endpoint coverage

Assisted-by: Codex
- Describe line and rectangle shape fields for generated API reference
- Mark the shape union as a type alias so its union renders correctly

Assisted-by: Codex
- Prefer PDFREST_LIVE_BASE_URL before the standard endpoint candidates
- Document live-test configuration and fallback behavior for contributors

Assisted-by: Codex
- Demonstrate typed rectangle and line construction
- Exercise tagging and report output metadata against a bundled PDF

Assisted-by: Codex
Declare the public literal as a TypeAlias and describe the semantic role
of each accepted spelling alongside the tagging requirement.

Assisted-by: Codex
Share single-field boundary and structure-type cases between payload,
client, and live tests. Check exact wire serialization and require local
validation failures to stop before transport execution.

Exercise invalid values through live body overrides and use the
20-page fixture to validate page selectors above the lower bound.

Assisted-by: Codex

This branch was successfully deployed

1 active deployment
ci-live — d9abf38c Deployed Oct 8, 2026 by datalogics-kam via Examples (Python 3.10) #541
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.

4 participants