Set Submit Url
Contents
[
Hide
]
PDF forms can be designed to submit their data to a web server when a user clicks a submit button. Using Aspose.PDF for Python, developers can programmatically configure a submit action for form fields. By setting a submit URL, the form can send user-entered data to a server when the button is clicked. This functionality is useful for workflows where PDF forms must submit information to web applications, databases, or processing services.
Using the FormEditor class from the aspose.pdf.facades module, developers can programmatically assign a submit URL to a button field in an existing PDF form.
- Open an existing PDF form.
- Locate a button field named Script_Demo_Button.
- Assign a URL where the form data will be submitted.
- Verify that the action was successfully applied.
- Save the updated PDF document.
import aspose.pdf as ap
import aspose.pdf.facades as pdf_facades
import sys
from os import path
sys.path.append(path.join(path.dirname(__file__), ".."))
from config import set_license, initialize_data_dir
def set_submit_url(input_file_name, output_file_name):
# Create FormEditor object
form_editor = pdf_facades.FormEditor()
# Set license
set_license()
# Open input PDF file
form_editor.bind_pdf(input_file_name)
# Set submit URL for the button
if not form_editor.set_submit_url(
"Script_Demo_Button", "http://www.example.com/submit"
):
raise Exception("Failed to set submit URL")
# Save output PDF file
form_editor.save(output_file_name)