Skip to content

Conversation

@KrishVij
Copy link

PDFBOX-3.6: Add ChangeTextColor example

This pull request adds a new example class ChangeTextColor to the PDFBox examples module
(org.apache.pdfbox.examples.pdmodel).

The example demonstrates how to modify the text color in an existing PDF by parsing its content streams,
identifying text sections, and injecting RGB color operators (rg and RG) immediately after
the BT (Begin Text) operator.


🔍What the example shows

  • Shows how to use PDFStreamParser to access and modify PDF operators.
  • Demonstrates rebuilding content streams with ContentStreamWriter.
  • Converts standard RGB values (0–255) into PDF-compatible color space (0.0–1.0).
  • Uses only public PDFBox API classes — no private/internal APIs.
    Before:
Screenshot 2025-10-30 220526 After: Screenshot 2025-10-30 220700

PS: Both are screenshot of a resume of mine


@KrishVij
Copy link
Author

KrishVij commented Nov 14, 2025

Can anybody at least tell me was my contribution not upto the mark it will mean a lot to me.

@THausherr
Copy link
Contributor

Sorry for the late reaction. I'm kinda undecided. The problem is that this will work only for very simple cases, where the text is in the top content stream.

@KrishVij
Copy link
Author

KrishVij commented Nov 14, 2025 via email

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