Hopding / pdf-lib

Create and modify PDF documents in any JavaScript environment
https://pdf-lib.js.org
MIT License
6.93k stars 663 forks source link

PDF Form Filling of NY CITY TAX FORM #1138

Open msingla1990 opened 2 years ago

msingla1990 commented 2 years ago

What were you trying to do?

We are trying to Edit below pdf document for various form fields present in it. We are able to fill values in Textboxes, Dates, Checkbox fields which have unique names with no issue. But when we try to set the value of checkbox which have many occurrence in pdf & having same name then it's picking up only first occurrence.

For Example: When you open up this pdf document you will see 4 checkboxes in succession and all of these checkbox have same name="period": 1 2 3 4 Jan 1-[ ] Apr 1-[ ] July 1- [ ] Oct 1- [ ] Mar 31 Jun 30
Sep 30 Dec 31

URL of pdf template: http://199.231.86.172/Dev/NYS-45.pdf

How did you attempt to do it?

const checkBox = form.getCheckBox("period"); checkBox.check();

What actually happened?

it's checking only first checkbox.

What did you expect to happen?

We want a capability to find a specific checkbox out of multiple with same name & to be able to set it's value as well.

How can we reproduce the issue?

You can use the same template and try to check any of them.

Is there any way to handle checkboxes with same name so that we can check any of them.

Version

1.17.1

What environment are you running pdf-lib in?

Node

Checklist

Additional Notes

No response

satinjeet commented 2 years ago

Seconded. I found a way to check the child tags and check the corresponding one ( Example here: https://github.com/Hopding/pdf-lib/issues/1185#issuecomment-1069657650 ), But any checkbox except the first one is empty when the form is flattened.