Skip to content

Conversation

@ajaykrdas
Copy link
Contributor

@ajaykrdas ajaykrdas commented Dec 15, 2025

What kind of change does this PR introduce?

Fixes: #1640

Checklist:

  • Unit Tests
  • Documentation
  • Update CHANGELOG.md
  • Ready to be merged
image

@ajaykrdas ajaykrdas changed the title Accessibility Issue: CS / cs Operator Error in Tagged Table #1640 Accessibility Issue: CS / cs Operator Error in Tagged Table Dec 15, 2025
.strokeColor('green')
.rect(cell.x, cell.y, cell.width, cell.height)
.stroke('green');
.stroke();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why those changes improve accessibility?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using fill('color') on shapes (e.g.
doc.rect(100, 100, 300, 200).fill('orange')

results in an accessibility parsing error:
“Error while parsing PDF Document (Operator 'cs' not allowed in this current state…)” (see attached report).
csnotallowed

To resolve this, I switched to an explicit color-setting approach, which eliminates the error and passes accessibility checks:

doc.fillColor('orange')
   .rect(100, 100, 300, 200)
   .fill();

Similarly, using stroke('color'):

doc
  .lineWidth(15)
  .rect(100, 100, 300, 200)
  .stroke('orange');

triggers a parsing error:
“Error while parsing PDF Document (Operator 'CS' not allowed in this current state…)”.
Parsing errorCSnotallowed

This is fixed by explicitly setting the stroke color before stroking:

doc
  .lineWidth(15)
  .strokeColor('orange')
  .rect(100, 100, 300, 200)
  .stroke();
image

The updated approach resolves the accessibility issues and has been verified with accessibility testing tools.

@blikblum
Copy link
Member

Checklist:

* [x]  Unit Tests

I can not find the test files

@blikblum
Copy link
Member

There's just a conflict in changelog

@ajaykrdas ajaykrdas requested a review from blikblum December 22, 2025 17:28
@blikblum blikblum merged commit 5505b6d into foliojs:master Dec 22, 2025
3 checks passed
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.

Accessibility Issue: CS / cs Operator Errors When Applying Fill Color in Tagged Table (PAC Validation Failure)

2 participants