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]: PDF.js not Performing Calculations on Interactive PDF Forms #18561

Closed
paritosh-mahale opened this issue Aug 5, 2024 · 12 comments · Fixed by #18566
Closed

[Bug]: PDF.js not Performing Calculations on Interactive PDF Forms #18561

paritosh-mahale opened this issue Aug 5, 2024 · 12 comments · Fixed by #18566

Comments

@paritosh-mahale
Copy link

paritosh-mahale commented Aug 5, 2024

Attach (recommended) or Link to PDF file

Lowes Measure sheet (2).pdf

Web browser and its version

Mozilla

Operating system and its version

Linux

PDF.js version

v4.5.136

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

Yes

Is a browser extension

No

Steps to reproduce the problem

  1. Open the attached PDF document in Adobe Reader.
  2. Enter values in the input fields.
  3. Observe that the total is automatically calculated using the hidden per-unit price field.
  4. Open the same PDF document using PDF.js.
  5. Enter values in the input fields.
  6. Notice that the total is not calculated.

What is the expected behavior?

PDF.js should perform the same calculations as Adobe Reader when values are entered into the input fields.

image

What went wrong?

PDF.js does not perform the calculations, and the total remains unchanged when values are entered into the input fields.

image

Link to a viewer

No response

Additional context

I am experiencing an issue with PDF.js when it comes to interactive PDF forms that involve calculations. I have a PDF document containing input fields for user data entry and hidden fields that perform calculations based on the input values. Specifically, when I open the document in Adobe Reader, entering values in the input fields automatically retrieves a per-unit price from a hidden field and calculates the total by multiplying the per-unit price by the quantity entered. However, this calculation is not happening when I open the same document using PDF.js.

@Snuffleupagus

This comment was marked as resolved.

@paritosh-mahale

This comment was marked as resolved.

@calixteman
Copy link
Contributor

If I enter a rate for Aluminum, then there's an error with either pdf.js or Acrobat, you should fix it and provide us a correct file.
If possible you should provide us a basic test case instead of a big file (it makes the debugging more complex).

@paritosh-mahale
Copy link
Author

there is not issue in Acrobat, we have given you a same file that we received and it's breaking in pdf.js only. in acrobat is working fine.

Test case is : Whenever we add quantity, Rate get calculated with the help of hidden filed and whenever rate updates the total also get updated immediately.

@calixteman
Copy link
Contributor

@paritosh-mahale
Copy link
Author

Please refer this recording, it's chrome browser and pdf.js
screen-capture (1).webm

@calixteman
Copy link
Contributor

It'd be nice to provide a clear STR instead of saying fuzzy things like "Enter values in the input fields.".
Really providing us a basic file with only 2,3 fields in order to clearly show what the problem is would be a way more helpful than a big pdf and fuzzy instructions to reproduce the issue.
See my answer in #18561 (comment), you answered me "there is not issue in Acrobat", I wrote something clear and if you test what I wrote in this comment in either Chrome, Acrobat or Firefox then it doesn't work correctly because of a wrong field name.
So again, please make a good use of our time in filing clear bug reports.

@calixteman
Copy link
Contributor

The embedded JS code used to calculate fields value is either using unexisting fields or has some invalid JS code !! so when we evaluate the C callback, there are some exceptions we don't catch when our competitors does.

@rahulrajpal2911
Copy link

Hi @calixteman
We understand that not all PDFs are causing trouble, but only this one. When we save it using any PDF viewer or editor, even some basic row-level multiplication is not happening. These PDFs are coming from a different source, and therefore, we are not allowed to edit them. We hope you understand our limitations. Also, with our limited expertise, we are not sure if this PDF is causing trouble.

@calixteman
Copy link
Contributor

It isn't a problem to not have a basic test case if you aren't able to produce one, but the minimal thing you can do is to provide a clear STR, for example:

  • on page 2, click in the field Qty for the line Aluminum and add 123
  • click on the field below

Expected results:

  • in the field Rate, we should have 12300
  • in the field Total (on the bottom of the page) we should have 12300

Actual results:
In both fields, Rate and Total, we've 0.

  • screenshots as you did.

@paritosh-mahale
Copy link
Author

Hi @calixteman
Please find below details:

Steps to reproduce:

  1. Open PDF document and go to page no 2.
  2. In "customer labor" table ( middle table) add Qty as 10 for Aluminum and click on next row in Qty column.

Expected behavior:

  • Rate for Aluminum should get calculated automatically by multiplying Qty by 10, so rate should become 100.
  • Also the Total ( In red, below table) should also be get calculated as 100 ( it's an total of rate)

Screenshot of expected result (from Adobe Reader)
image

Actual behavior:

  • The calculation is not getting trigger to calculate the rate and total based on Qty provided.

Screenshot of actual result (from pdf.js)
image

@rahulrajpal2911
Copy link

Hi @calixteman
Is this information helpful?

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.

4 participants