Fix to set color space from color convenience ops #794
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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