Skip to content

PDFBOX-5074: use the tint transform of DeviceN if a spot colorant isn't white at zero tint - #534

Closed
valerybokov wants to merge 2 commits into
apache:trunkfrom
valerybokov:fix-PDFBOX-5074
Closed

valerybokov wants to merge 2 commits into
apache:trunkfrom
valerybokov:fix-PDFBOX-5074

Conversation

@valerybokov

Copy link
Copy Markdown

Problem

Problem
In PDFBOX-5074 (https://issues.apache.org/jira/browse/PDFBOX-5074), a DeviceN space with one spot colorant (PANTONE 342 C) is painted at tint 0.4. It renders as a dark green (RGB ≈ 0, 0.16, 0.12), so the tint ramp runs from black to green. Adobe Reader draws a white background with a light green fill.

Cause
When a DeviceN has an attributes dictionary, PDDeviceN converts to RGB by multiplying the RGB values of its colorants (toRGBWithAttributes). That only works if a colorant with tint 0 is white, so that no ink leaves the result unchanged.

In this file the spot colorant's Separation function maps tint 0 to black (0,0,0). Multiplying by that darkens everything, and the space ends up black-to-green. The tint transform to the CMYK alternate space gives white at tint 0.

Change

  • PDDeviceN: If a spot colorant that the conversion uses (a spot colorant not replaced by a process colorant) is not white at zero tint, toRGB and toRGBImage use the tint transform and the alternate space instead of the attributes.
    • "Not white" means any RGB channel below 0.9.
    • The result is computed once, on first use, and reset in setAttributes.
    • Spaces whose spot colorants are white at zero tint keep the attributes path exactly as before.
  • PDSeparation: Adds a public getTintTransform(). PDDeviceN needs it to evaluate tint 0 directly. PDSeparation.toRGB caches by (int)(tint*255), so calling it with 0 would make every later tint below 1/255 return the tint-0 color.

Notes

  • The 0.9 threshold is a heuristic. I did not run the Altona suite, so I have no wider corpus data on it.
  • The plain Separation square in PDFBOX-5074_2.pdf still renders dark. The file's own function defines it as black-to-green, so that is correct and unchanged.

Per https://www.apache.org/legal/generative-tooling.html: portions of this PR were
produced with assistance from Claude Code (Anthropic), based on a bug was described in Apache PDFBOX Issue Tracker.

I've reviewed the generated code and confirm to the best of my knowledge that the output does not include any
third-party copyrighted material and is compatible with the Apache License 2.0.

@THausherr

THausherr commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Yes thanks, this works fine with the 2 files from that issue + the 2 files from the linked GS ticket and no regressions. This includes the Altona test files.

asf-gitbox-commits pushed a commit that referenced this pull request Sep 22, 2026
…'t white at zero tint, by Valery Bokov and Claude Code; closes #534

git-svn-id: https://svn.apache.org/repos/asf/pdfbox/branches/3.0@1938425 13f79535-47bb-0310-9956-ffa450edef68
asf-gitbox-commits pushed a commit that referenced this pull request Sep 22, 2026
…'t white at zero tint, by Valery Bokov and Claude Code; closes #534

git-svn-id: https://svn.apache.org/repos/asf/pdfbox/branches/2.0@1938427 13f79535-47bb-0310-9956-ffa450edef68
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