You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey,
Im trying to use pypdf to fill some templates. We now moved to testing and noticed that some of the form fields are not filled properly because of some field naming issues. I digged a bit and figured out that field names including a . causing the problem.
In our use case we got multiple categories in which all of them include a 1_Name Field. When inspecting the pdf in Acrobat I figured that the fields actually named 1_Name2.1_Name, ... and so on. With get_form_text_field I only get back the first field. While get_fields results in two fields one named 1_Name and the second just 2. (See Output further down)
While checking with pdftk the field names are retrieved properly.
Since I can't share the initial pdf I was testing with I created a small sample pdf with just two text fields named 1_Name and 2.1_Name
To confirm it's indeed the . causing the problem I tested renaming the 2.1_Name field to 2_1_Name which works as expected.
As a side effect of this problem all fields named x.1_Name are filled with the same value when filling the fields. When running update_page_form_field_values with "1_Name": "test, both fields are filled with test. I did not include this in the example as I think this will be fixed when namings are correct.
Environment
Which environment were you using when you encountered the problem?
Renaming all fields to not include a . is an option I would like to dodge since we have quite a number of Templates.
I hope this is an easy fix on your side. Could you let me know if you are looking into this issue and what timeframe to expect a possible fix?
Best,
The text was updated successfully, but these errors were encountered:
Also if you look at the pdf source you will find the first field named "1_Name"with no parent and the second one one also named "1_Name" has a parent field (sort of grouping) has a parent named 2 so the names are correct.
for the get_text_form, the second one hides/ovewrites the first one.
If you want to see both use .get_form_text_fields(True)
Hey,
Im trying to use pypdf to fill some templates. We now moved to testing and noticed that some of the form fields are not filled properly because of some field naming issues. I digged a bit and figured out that field names including a
.
causing the problem.In our use case we got multiple categories in which all of them include a
1_Name
Field. When inspecting the pdf in Acrobat I figured that the fields actually named1_Name
2.1_Name
, ... and so on. Withget_form_text_field
I only get back the first field. Whileget_fields
results in two fields one named1_Name
and the second just2
. (See Output further down)While checking with pdftk the field names are retrieved properly.
Since I can't share the initial pdf I was testing with I created a small sample pdf with just two text fields named
1_Name
and2.1_Name
To confirm it's indeed the
.
causing the problem I tested renaming the2.1_Name
field to2_1_Name
which works as expected.As a side effect of this problem all fields named
x.1_Name
are filled with the same value when filling the fields. When runningupdate_page_form_field_values
with"1_Name": "test
, both fields are filled withtest
. I did not include this in the example as I think this will be fixed when namings are correct.Environment
Which environment were you using when you encountered the problem?
$ python -m platform macOS-13.1-arm64-arm-64bit $ python -c "import pypdf;print(pypdf.__version__)" 3.1.0
Initially I was running on Version 2.10 - I updated to 3.1 with the same result.
Code + PDF
This is a minimal, complete example that shows the issue:
field_sample.pdf
Output
Renaming all fields to not include a
.
is an option I would like to dodge since we have quite a number of Templates.I hope this is an easy fix on your side. Could you let me know if you are looking into this issue and what timeframe to expect a possible fix?
Best,
The text was updated successfully, but these errors were encountered: