PyMuPDF
PyMuPDF copied to clipboard
Interactive(smartform) form PDF calculation not working in pymupdf
What we were trying to do?
We are trying to fill the interactive form values using the pymupdf widget field and generating a new pdf.
Description of the bug
We are trying to access the field in smart pdf form and fill in the value using the field.field_value. once the update is done, we expect the total field in the pdf to be updated. but that is not working as expected
Sample doc
To Reproduce, the sample code below
import fitz
doc = fitz.open('widgettest12.pdf') # new or existing PDF
page = doc[0]
#print (page)
#page_wid = page.widget()
for field in page.widgets():
print (field.field_name)
if (field.field_name == 'num2'):
field.field_value = '201'
field.update()
if (field.field_name == 'num1'):
field.field_value = '150'
field.update()
if (field.field_name == 'Text4'):
field.update()
#field.script_format
#field.script_change
#page = doc.reload_page(page)
doc.save("widgettest_result.pdf")
doc.close()
Screenshots of actual result

Expected behaviour

configuration used
- Operating system : Windows 10
- Python version: 3.10
- PyMuPDF version:1.20.0