Skip to content

The colour of the text, and the limit it reports rather than hides - #109

Merged
tannevaled merged 1 commit into
mainfrom
the-colour-of-the-text
Oct 11, 2026
Merged

tannevaled merged 1 commit into
mainfrom
the-colour-of-the-text

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

text-color is claimed, through pdfops textcolour in go-pdfkit/ops v0.16.0
over go-pdfkit/reader v0.8.0.

covered       82
not covered   32
parity       71.9% (82/114), every claim verified

It needed a new fact in reader first

An Operation now says which bytes of the stream it is, so a content
stream can be edited in place. The alternative was re-serialising every
operand, including an inline image's still-encoded bytes, where a formatter
that is merely lossless-for-objects can change what the image means.

A byte search cannot stand in for it. In the test's fixture:

(BT in a string) Tj  BT /F1 12 Tf ET
 ^ a search finds 1                    ← inside somebody's text
                     ^ the scan says 20

⛔ The claim is honest because the tool reports its own limit

Text drawn through a Form XObject is not recoloured: an XObject is
shared, so recolouring one would change pages the caller did not name. So
the verb counts what it could not reach and says so:

3 drawing(s) were not recoloured: text inside a form or an image is shared
between pages, so recolouring it for one page would change others

The failure that would have made this claim dishonest is a document coming
back unchanged while looking converted
— and that is precisely the one it
refuses to be silent about.

Two defects found building it, neither by a report

  • setting a colour before each text object is not enough. A text object
    that sets its own colour overrides it, so a page whose paragraphs said
    1 0 0 rg came out unchanged while the tool reported success. Every colour
    operator inside a text object is blanked now;
  • a page both recoloured and watermarked came back in its original
    colours.
    decorate rebuilt Contents from the source's parts and threw
    the rewritten stream away, with nothing failing. The mutation restoring that
    behaviour is caught.

Measured 2026-10-11 against BentoPDF 3a5f146 (v2.8.8, 114 tools), pdfops
and ops at v0.16.0, reader v0.8.0, ooxml v0.2.0, opc v0.1.0, odf
3d1deee (= v0.7.0), convert 45fbb5d, render 3bb5dcf, app
1feda5d, rtf 6bc4897, markdown eafebfd, data 128b6c7.

🤖 Generated with Claude Code

text-color is claimed, through `pdfops textcolour` in go-pdfkit/ops v0.16.0
over go-pdfkit/reader v0.8.0.

It needed a new fact in reader first: an Operation now says WHICH BYTES of the
stream it is, so a content stream can be edited in place. The alternative was
re-serialising every operand, including an inline image's still-encoded bytes,
where a formatter that is merely lossless-for-objects can change what the image
means. A byte search cannot stand in for it: "BT" appears inside strings and
inside an inline image's data, and in the test's fixture a search finds index 1
— in the middle of somebody's text — where the scan reports 20.

⛔ The claim is honest because the tool reports its own limit. Text drawn
through a Form XObject is not recoloured, since an XObject is SHARED and
recolouring one would change pages the caller did not name — so the verb COUNTS
what it could not reach and says so. The failure that would have made this
dishonest is a document coming back unchanged while looking converted, and that
is precisely the one it refuses to be silent about.

Two defects were found building it, neither by a report:

  - setting a colour before each text object is not enough, because a text
    object that sets its OWN colour overrides it. A page whose paragraphs said
    "1 0 0 rg" came out unchanged while the tool reported success.
  - a page both recoloured and watermarked came back in its original colours:
    `decorate` rebuilt Contents from the source's parts and threw the
    rewritten stream away, with nothing failing.

Pasted from the tool's own output:

    covered       82
    not covered   32
    parity       71.9% (82/114), every claim verified

Measured 2026-10-11 against BentoPDF 3a5f146 (v2.8.8, 114 tools), pdfops and
ops at v0.16.0, reader v0.8.0, ooxml v0.2.0, opc v0.1.0, odf 3d1deee
(= v0.7.0), convert 45fbb5d, render 3bb5dcf, app 1feda5d, rtf 6bc4897,
markdown eafebfd, data 128b6c7.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit 7db100d into main Oct 11, 2026
9 checks passed
@tannevaled
tannevaled deleted the the-colour-of-the-text branch October 11, 2026 17:25
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