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

[Bug]: JS of a button is not executed #19378

Open
g19i85g opened this issue Jan 24, 2025 · 2 comments
Open

[Bug]: JS of a button is not executed #19378

g19i85g opened this issue Jan 24, 2025 · 2 comments
Labels

Comments

@g19i85g
Copy link

g19i85g commented Jan 24, 2025

Attach (recommended) or Link to PDF file

three_buttons_same_name.pdf

Web browser and its version

Firefox 134.0 (64-Bit)

Operating system and its version

Linux

PDF.js version

v4.10.38

Is the bug present in the latest PDF.js version?

Yes

Is a browser extension

No

Steps to reproduce the problem

  1. open the PDF in PDF.js
  2. klick on the button "set text to BBB"

What is the expected behavior?

The text field should contain “BBB”.

Image

What went wrong?

If several buttons with the same name exist. Only the JavaScript of the first button is executed, regardless of which button is pressed.

Link to a viewer

No response

Additional context

No response

@Snuffleupagus
Copy link
Collaborator

Part of the problem appears to be at

if (annotations.length > 0) {
obj = annotations[0];
obj.send = send;
}
since we're only parsing the first button here.

The other buttons don't get their own Field-instances, but are only handled via

const otherFields = annotations.slice(1);
and
if (otherFields.length > 0) {
obj.siblings = otherFields.map(x => x.id);
}
field = new Field(obj);

This is as far as I've got, given my very limited knowledge of the scripting-API. /cc @calixteman

@Youngemmy5956
Copy link

Youngemmy5956 commented Jan 31, 2025

@g19i85g @Snuffleupagus

I created a pull request that fixed the current issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants