-
Notifications
You must be signed in to change notification settings - Fork 1.4k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
How can I update data obtained with getField? #509
Comments
Have a look at updatePageFormFieldValues in the PdfFileWriter class. You will need to call Edit: sorry, I just saw that you want to update the value of dropdowns as well. I haven't worked out a method for doing this yet. |
Too bad… I know this can be done: https://yoongkang.com/blog/pdf-forms-with-python/ |
You could try extending the class. I did this (snippet here - #232 (comment) ) in order to make form fields read-only. I think it would be a similar process, except that you would set a different attribute. |
Okay, this is somewhat above my level, but I will give it a chance. Thank you! |
You're welcome. I hope you are able to get it to work. That code snippet was my first attempt at extending the PdfFileWriter class, so I only went as far as required to get it to do what I wanted (modifying the "/Ff" attribute). But I suspect if you have a play around with modifying the attributes required for the dropdown (it might help to open your PDF form in a text editor like Notepad++ to see how the values are being written by Adobe), you can get it to work. Note that you'll need to use the extended class (PDFModifier in my code snippet) rather than the original PdfFileWriter class to access the extra methods. |
I have tried playing with the code just a bit, but there's too many things beyond my skill level at this moment. I will probably just remake the PDF-s to have only text boxes and hope somebody fixes that in PyPDF2 at some point. |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Hi! I am quite new to PyPDF2 and I am mostly using snippets of code I have found on the net. What I do is simply filling PDF forms created with Adobe Acrobat XI Pro. While it works perfectly with text fields, I am having trouble setting values of dropdown lists.
I was able to determine that what PyPDF2 sees is (with getField):
{'/FT': '/Ch', '/T': DocumentType', '/Ff': 4325378, '/V': 'D', '/DV': 'W'}
In case of getTextFields, what it shows is:
{'/FT': '/Tx', '/T': 'SupervisorName', '/Ff': 29360130}
But I haven't found a similar method for updating values of those. How can I directly manipulate/update the value of /V here? Can I just replace this entire element with another one, where /V is i.e. "P" (which is one of the choices in the PDF)?
I seek counsel.
The text was updated successfully, but these errors were encountered: