Skip to content

widget.script_calc returns None when JavaScript is evidently present #4683

@poffertje

Description

@poffertje

Description of the bug

I am using a script to automatically fill in a PDF form with widgets. In the form I am filling out, there are character counters next to each text input widget. The counters get updated automatically when I input the text using Adobe Acrobat, but this does not happen when I update the value of the text widget using PyMuPDF. Upon further inspection, I discovered that widget.script_calc returns None for the fields that clearly have a counter implemented.

How to reproduce the bug

Here is a sample code:

with fitz.open(form_path) as doc:
    for page in doc:
        for widget in page.widgets():
            if widget.field_name == "WbsoProjectomschrijving":
                widget.field_value = "hello world"
                print(f"{widget.field_name=}, {widget.field_value=}, {widget.script_calc=}")

            if widget.field_name == "tellerProjectomschrijving":
                print(f"{widget.field_name=}, {widget.field_value=}, {widget.script_calc=}")

            widget.update()

    doc.save(output_path)

programmatuur.pdf

PyMuPDF version

1.26.4

Operating system

Windows

Python version

3.11

Metadata

Metadata

Assignees

No one assigned

    Labels

    not a bugnot a bug / user error / unable to reproduce

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions