Skip to content
Discussion options

You must be logged in to vote

Got it working with version 1.23.26. (Don't know what the exact issue has been.)

import fitz  # PyMuPDF

doc = fitz.open()
page = doc.new_page()

# Define the items for the combo box
combo_items = ['first', 'second', 'third']

# Create a combo box field
combo_box = fitz.Widget()  # create a new widget
combo_box.field_type = fitz.PDF_WIDGET_TYPE_COMBOBOX
combo_box.field_name = "myComboBox"
combo_box.field_value = combo_items[0]
combo_box.choice_values = combo_items
combo_box.rect = fitz.Rect(50, 50, 200, 75)  # position of the combo box
combo_box.script_stroke = """
var value = event.value;
var optionalContentGroups = this.getOCGs();
for(var id in optionalContentGroups) {
    var ocg = opt…

Replies: 9 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@jamie-lemon
Comment options

@stefaneidelloth
Comment options

Comment options

You must be logged in to vote
2 replies
@JorjMcKie
Comment options

@stefaneidelloth
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by stefaneidelloth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants
Converted from issue

This discussion was converted from issue #3180 on February 21, 2024 15:43.