Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to set color space from color convenience ops #794

Merged
merged 1 commit into from
Aug 18, 2022

Conversation

jsvine
Copy link
Contributor

@jsvine jsvine commented Aug 15, 2022

Pull request

Filing this PR as described (and as requested) in #779. In brief:

Section 4.5 of the PDF reference says: "Color values are interpreted according to the current color space, another parameter of the graphics state. A PDF content stream first selects a color space by invoking the CS operator (for the stroking color) or the cs operator (for the non-stroking color). It then selects color values within that color space with the SC operator (stroking) or the sc operator (nonstroking). There are also convenience operators—G, g, RG, rg, K, and k—that select both a color space and a color value within it in a single step."

Previously, those convenience operators did not set the color space. This commit, following on filed issue #779, fixes this.

How Has This Been Tested?

The PR also adds a test to demonstrate that, at least for the do_rg method, the fix works as intended. The other methods should, at least in theory, work analogously. I can try to find PDF(s) that allow for testing those other ones if needed.

Note: I added the test to test_converter.py since that seemed to be the closest fit among pre-existing test files, but I can move it elsewhere if desired.

Checklist

  • I have read CONTRIBUTING.md.
  • I have added a concise human-readable description of the change to CHANGELOG.md.
  • I have tested that this fix is effective or that this feature works.
  • [n/a] I have added docstrings to newly created methods and classes.
  • [n/a] I have updated the README.md and the readthedocs documentation. Or verified that this is not necessary.

Section 4.5 of the PDF reference says: "Color values are interpreted
according to the current color space, another parameter of the graphics
state. A PDF content stream first selects a color space by invoking the
CS operator (for the stroking color) or the cs operator (for the
non-stroking color). It then selects color values within that color
space with the SC operator (stroking) or the sc operator (nonstroking).
There are also convenience operators—G, g, RG, rg, K, and k—that select
both a color space and a color value within it in a single step."

Previously, those convenience operators did *not* set the color space.
This commit, following on filed issue pdfminer#779, fixes this. It also adds a
test to demonstrate that, at least for the do_rg method, the fix works
as intended.
@pietermarsman pietermarsman merged commit ad6587c into pdfminer:master Aug 18, 2022
@pietermarsman
Copy link
Member

Perfect PR! Thanks again!

@jsvine
Copy link
Contributor Author

jsvine commented Aug 18, 2022

Thanks for the kind words, and thanks for the merge!

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