Delete List Item
Contents
[
Hide
]
List box fields in PDFs allow users to select one or multiple predefined options. Using Aspose.PDF for Python, developers can programmatically remove items from these fields.
This article explains how to delete the ‘UK’ item from a list box field named ‘Country’, ensuring the field only contains the desired options.
The FormEditor class provides the ‘del_list_item’ method to remove a specific item from a list box field.
- Open an existing PDF form.
- Create a FormEditor object.
- Bind the PDF document to the FormEditor.
- Delete the “UK” item from the “Country” list box field.
- Save the updated document.
from io import FileIO
import sys
from os import path
import aspose.pdf as ap
import aspose.pdf.facades as pdf_facades
sys.path.append(path.join(path.dirname(__file__), ".."))
from config import set_license, initialize_data_dir
def del_list_item(infile, outfile):
# Create FormEditor object
form_editor = pdf_facades.FormEditor()
# Bind document to FormEditor
form_editor.bind_pdf(infile)
# Delete list item from list box field
form_editor.del_list_item("Country", "UK")
# Save updated document
form_editor.save(outfile)