Skip to content

PDFCLOUD-5548 Add "Add to PDF" client methods#13

Merged
datalogics-kam merged 23 commits intopdfrest:mainfrom
datalogics-cgreen:pdfcloud-5464-add-to-pdf
Feb 13, 2026
Merged

PDFCLOUD-5548 Add "Add to PDF" client methods#13
datalogics-kam merged 23 commits intopdfrest:mainfrom
datalogics-cgreen:pdfcloud-5464-add-to-pdf

Conversation

@datalogics-cgreen
Copy link
Copy Markdown
Contributor

@datalogics-cgreen datalogics-cgreen commented Jan 20, 2026

Adds client support for pdfRest “add to PDF” operations (attachments, images, text) across sync/async APIs, including new payload/type models and request wiring.

Expands unit and live test coverage for each endpoint with validation, request customization, error handling, and async flows; add a small graphics test helper and PNG fixture to support image cases.

@datalogics-gwalczak datalogics-gwalczak changed the title Pdfcloud 5464 add to pdf PDFCLOUD-5464 add to pdf Jan 21, 2026
@datalogics-cgreen datalogics-cgreen changed the title PDFCLOUD-5464 add to pdf PDFCLOUD-5548 add to pdf Jan 30, 2026
@datalogics-cgreen datalogics-cgreen changed the title PDFCLOUD-5548 add to pdf PDFCLOUD-5548 Add "Add Text", "Add Image" client methods Jan 30, 2026
@datalogics-cgreen datalogics-cgreen changed the title PDFCLOUD-5548 Add "Add Text", "Add Image" client methods PDFCLOUD-5548 Add "Add to PDF" client methods Jan 30, 2026
@datalogics-cgreen datalogics-cgreen marked this pull request as ready for review February 6, 2026 22:36
@datalogics-cgreen datalogics-cgreen marked this pull request as draft February 10, 2026 17:51
@datalogics-cgreen datalogics-cgreen marked this pull request as ready for review February 10, 2026 21:17
Copy link
Copy Markdown
Contributor

@datalogics-kam datalogics-kam left a comment

Choose a reason for hiding this comment

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

I was looking mostly for "code that Codex shouldn't have changed", so please consider this a pass 1.

Thanks for your effort here.

Comment thread src/pdfrest/models/_internal.py Outdated
Comment thread src/pdfrest/models/_internal.py Outdated
Comment thread src/pdfrest/models/_internal.py Outdated
Comment thread src/pdfrest/models/_internal.py Outdated
Comment thread src/pdfrest/models/_internal.py Outdated
Comment thread src/pdfrest/models/_internal.py
Comment thread src/pdfrest/models/_internal.py Outdated
@datalogics-cgreen datalogics-cgreen force-pushed the pdfcloud-5464-add-to-pdf branch 2 times, most recently from 935272e to e6e9bff Compare February 11, 2026 22:43
@datalogics-cgreen
Copy link
Copy Markdown
Contributor Author

A lot of changes to _internal.py are now eradicated.

Copy link
Copy Markdown
Contributor

@datalogics-kam datalogics-kam left a comment

Choose a reason for hiding this comment

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

There are cases here where it could be tightened up with Pydantic.

Also, use good typing in the client interface. Sure, our system will let them violate type and send "3" to a parameter and Pydantic will fix it...but the type system should guide the coder to using accurate types.

Comment thread src/pdfrest/models/_internal.py Outdated
Comment thread src/pdfrest/models/_internal.py
Comment thread src/pdfrest/models/_internal.py Outdated
Comment thread src/pdfrest/types/public.py Outdated
Comment thread src/pdfrest/types/public.py Outdated
Comment thread src/pdfrest/types/public.py Outdated
Comment thread src/pdfrest/types/public.py Outdated
Comment thread src/pdfrest/types/public.py Outdated
Comment thread src/pdfrest/models/_internal.py Outdated
Copy link
Copy Markdown
Contributor

@datalogics-kam datalogics-kam left a comment

Choose a reason for hiding this comment

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

Getting closer, but a few things to fix

  • Custom validation of RGB/CMYK is actually not needed (and it would remove two functions that caused coverage threshold failure)
  • In the public interface, numbers should not have str alternatives in the typing. Yes, it would work if mistyped in the code, but the type hinting should be accurate.

Comment thread src/pdfrest/models/_internal.py Outdated
Comment thread src/pdfrest/models/_internal.py Outdated
Comment thread src/pdfrest/types/public.py Outdated
Comment thread src/pdfrest/types/public.py
Comment thread src/pdfrest/models/_internal.py
Comment thread src/pdfrest/models/_internal.py
Copy link
Copy Markdown
Contributor

@datalogics-kam datalogics-kam left a comment

Choose a reason for hiding this comment

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

I think it's pretty ok in design, but I fall back on Codex for reviewing tests, and so could you ask Codex to fix up the tests?

Maybe supply it a ducky in other graphic formats.

Thanks!

Review Summary

Thanks for the updates here. I validated the MIME-coverage question and have one concrete testing gap to call out.

Findings

  1. Image MIME variant coverage is not exhaustive yet (unit + live).
    • PdfAddImagePayload allows image/jpeg, image/png, image/tiff, and image/gif (/Users/kam/src/dl/pdfrest-python/src/pdfrest/models/_internal.py:1163).
    • Current unit tests cover jpeg, gif, and png, but I did not find a positive-path case for tiff.
      • jpeg: /Users/kam/src/dl/pdfrest-python/tests/test_add_image_to_pdf.py:25
      • gif: /Users/kam/src/dl/pdfrest-python/tests/test_add_image_to_pdf.py:274
      • png: /Users/kam/src/dl/pdfrest-python/tests/test_add_image_to_pdf.py:91
    • Live tests currently exercise a single uploaded PNG fixture and do not enumerate all accepted image MIME variants:
      • /Users/kam/src/dl/pdfrest-python/tests/live/test_live_add_image_to_pdf.py:24

What I’m not flagging

  • I am not flagging the float/string coercion point as a correctness bug. Pydantic coercion there is valid unless strict validation is explicitly intended.
  • I am not flagging commit-subject style in this review.

Suggested follow-up

  • Add one unit positive test for image/tiff in test_add_image_to_pdf.py.
  • Optionally add a live parameterized MIME matrix (jpeg/png/tiff/gif) if we want full server-parity coverage for each accepted literal.

Use explicit channel tuple types for add-text colors:
- `text_color_rgb` -> `tuple[RgbChannel, RgbChannel, RgbChannel]`
- `text_color_cmyk` -> `tuple[CmykChannel, CmykChannel, CmykChannel, CmykChannel]`

Assisted-by: Codex
- Remove `int` in favor of `float` wherever both were accepted
- `page` requires literal `"all"`, not any `str`

Assisted-by: Codex
- Rename to "is_right_to_left" for readability
- Keep "is_rtl" alias

Assisted-by: Codex
- Pydantic models get `model_dump_json`
- Everything else gets `to_json`

Assisted-by: Codex
Add missing sync and async tests for add_text_to_pdf local validation:
- reject non-PDF input files
- reject page values below 1
- reject text objects that provide both RGB and CMYK colors

Assisted-by: Codex
Add high-value live assertions for add_image_to_pdf and add_text_to_pdf
(sync + async): verify output file size is positive and warning is None.

Assisted-by: Codex
Validators are outmoded by other validation

Update tests

Assisted-by: Codex
@datalogics-kam datalogics-kam merged commit ea5eb66 into pdfrest:main Feb 13, 2026
14 checks passed
@datalogics-cgreen datalogics-cgreen deleted the pdfcloud-5464-add-to-pdf branch February 13, 2026 21:32
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.

2 participants