I am currently looking to set a face and export value to a PDF combobox using the good PyMuPDF module but I can't find the way. Normally, using Adobe API Javascript it would be something like this : f.setItems( ["Ohio", "OH"], ["Oregon", "OR"], ["Arizona", "AZ"] );
I am wondering if I it would be possible to apply something like this:
import fitz
myPDFfile = r"C:\temp\myPDFfile.pdf"
with fitz.open(myPDFfile) as doc:
for page in doc:
widgets = page.widgets()
for widget in widgets:
if widget.field_type_string in ('ComboBox'):
print('widget.field_name', widget.field_name, 'widget.field_value', widget.field_value)
if widget.field_name == 'ComboBox1':
print('widget.field_name',widget.field_name)
widget.choice_values=( ["Ohio", "OH"], ["Oregon", "OR"], ["Arizona", "AZ"] )
widget.field_value = 'test'
widget.update()
doc.saveIncr()
This code is making crash my Jupyter Notebook Kernel. The only way to use it is by correcting the following line: widget.choice_values= ["Ohio", "Oregon", "Arizona"]
but it wont set any export value the combobox.
Any ideas or is something not available yet using this module?
source https://stackoverflow.com/questions/76275409/adding-pdf-values-and-export-values-to-combobox-using-pymupdf
Comments
Post a Comment