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

[Feature]: Optional Content Radio Button Groups #18823

Open
agrahn opened this issue Sep 30, 2024 · 3 comments · May be fixed by #18825
Open

[Feature]: Optional Content Radio Button Groups #18823

agrahn opened this issue Sep 30, 2024 · 3 comments · May be fixed by #18825

Comments

@agrahn
Copy link

agrahn commented Sep 30, 2024

Is the feature relevant to the Firefox PDF Viewer?

Yes

Feature description

The PDF spec defines the /RBGroups entry in the optional content configuration dictionary. It allows OCGs to be to added to groups of OCGs that follow the radio-button paradigm: From all OCGs within a Radio Button Group only one can be enabled at a time. Enabling an OCG, e. g. in the Layers tab of the PDF viewer, automatically hides the previously visible OCG in that group. An OCG can be a member of multiple Radio Button Groups. The attached example PDF has two radio button groups, where one OCG, "3", belongs to both radio-button groups. If that one is enabled, any currently visible OCG belonging to the rb groups is hidden. There is also one OCG, "7", which is unrelated to the rb groups.

Other PDF viewers

The attached PDF opened in KDE Okular which correctly implements OC radio button groups:

radioBtnGrp.pdf

rbgrpsEx

@calixteman
Copy link
Contributor

@agrahn I think you've a patch ready for this feature, if it's correct, would you mind to make a PR please ?
It'd nice to have an integration test if it's possible.

@agrahn
Copy link
Author

agrahn commented Sep 30, 2024

@agrahn It'd nice to have an integration test if it's possible.

I am trying to figure out how to do an integration test. I followed the instructions on testing applied on the master branch first, just to get familiar with the procedure, but already npx gulp makeref in the master branch ends with errors. What do I have to do?

@agrahn agrahn linked a pull request Sep 30, 2024 that will close this issue
@calixteman
Copy link
Contributor

calixteman commented Oct 1, 2024

You can create a file optional_content_spec.mjs similar to https://github.com/mozilla/pdf.js/blob/master/test/integration/annotation_spec.mjs, with a test doing something like:

  • click on the sidebar button
  • click on the layers button
  • click on the buttons in the pdf
  • check that the radio buttons in the sidebar have the correct state.
    something like that...

Edit:
And I forgot to mention that to run the integration tests you just have to use the command gulp integrationtest.
In order to avoid to run everything you can use fit(... in your test (f === focus), and to make it faster you use gulp integrationtest --noChrome.

agrahn added a commit to agrahn/pdf.js that referenced this issue Oct 2, 2024
…ozilla#18823.

The code parses the /RBGroups entry in the OC configuration dict and adds the property `rbGroups' to instances of the OptionalContentGroup class. rbGroups takes an array of Sets, where each Set instance represents an RB group the OptionalContentGroup instance is a member of. Such a Set instance contains all OCG ids within the corresponding RB group. RB groups an OCG is associated with are processed when its visibility is set to true, as required by the PDF spec.
agrahn added a commit to agrahn/pdf.js that referenced this issue Oct 2, 2024
…ozilla#18823.

The code parses the /RBGroups entry in the OC configuration dict and adds the property `rbGroups' to instances of the OptionalContentGroup class. rbGroups takes an array of Sets, where each Set instance represents an RB group the OptionalContentGroup instance is a member of. Such a Set instance contains all OCG ids within the corresponding RB group. RB groups an OCG is associated with are processed when its visibility is set to true, as required by the PDF spec.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants