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]: Form Field Calculation Triggering Unexpectedly or not getting trigger at all. #18532

Closed
paritosh-mahale opened this issue Aug 1, 2024 · 8 comments · Fixed by #18552
Closed
Assignees
Labels

Comments

@paritosh-mahale
Copy link

Attach (recommended) or Link to PDF file

Description:

I am using the pdf.js library to rendering PDFs that contain form fields with embedded formulas. When I open the PDF in any pdf reader and enter values, the formula in the specific field is triggered, and the result is calculated correctly for that field only.

However, when using pdf.js, entering a value in one field causes the formulas in all fields to be calculated, not just the one being edited.

image

In another pdf when I am entering any value it is suppose to do an calculation like this

image

but is not at all getting triggered

image

Expected Behavior:
Entering a value in a specific form field should trigger the formula and calculate the result for that field only.

I have been struggling with this issue for the past 2-3 days and would greatly appreciate any assistance or guidance. Thank you in advance for your help.

Web browser and its version

firefox 127.0

Operating system and its version

Linux

PDF.js version

pdfjs-dist: 3.11.174

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

Yes

Is a browser extension

No

Steps to reproduce the problem

Open any pdf which is having formulas in it.

What is the expected behavior?

Entering a value in a specific form field should trigger the formula and calculate the result for that field only.

What went wrong?

Either not triggering the calculation or triggering calculation for the filed which is not expected.

Link to a viewer

No response

Additional context

No response

@calixteman
Copy link
Contributor

We need to have the pdf to debug the potential issue: without it, it's impossible to guess what's wrong exactly.

@rahulrajpal2911
Copy link

rahulrajpal2911 commented Aug 1, 2024

Hi @calixteman
Thank you for your prompt reply. Here, I have attached a PDF for your reference. @paritosh-mahale and I are working on this and found this issue.

image

Sample.pdf

@calixteman
Copy link
Contributor

An empty product should be 0 and not 1:

event.value = cFunction === "PRD" ? 1 : 0;

@rahulrajpal2911
Copy link

@calixteman Will this check resolve the other issue as well? In the PDF snapshot shared by @paritosh-mahale, you can see that the amount is being calculated from the rate by default when we enter the quantity in any row. This is affecting the solution we created using pdf.js.

@calixteman
Copy link
Contributor

I don't know, you didn't provide the pdf for the other issue...
It'd be a way easier for everybody and make a good use of our time to provide the required information when you file the bug:
image
Isn't it (I mean the sentence Attach (recommended) or Link to PDF file) clear enough ?

@Snuffleupagus
Copy link
Collaborator

In addition to everything said in #18532 (comment), please also note that it's not really "allowed" to report multiple different problems in one issue (since that makes tracking things much more difficult).

@rahulrajpal2911
Copy link

rahulrajpal2911 commented Aug 1, 2024

@calixteman and @Snuffleupagus I understand what you said and I am aligned with that. Your time is valuable, and since this is an open-source library, the support we are receiving from you is a significant help for us. The other PDF is restricted and cannot be shared in a public forum. If possible, could we share it via email? This is the last piece pending in our solution, and we are a bit worried about it.

Thank you for providing us with this wonderful library. Cheers!

@rahulrajpal2911
Copy link

@calixteman / @Snuffleupagus Here is the attached PDF. We recreated it without restrictions.

calculation-issue.pdf

calixteman added a commit to calixteman/pdf.js that referenced this issue Aug 2, 2024
calixteman added a commit to calixteman/pdf.js that referenced this issue Aug 2, 2024
@calixteman calixteman linked a pull request Aug 2, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants