Create Submit Button

Contents
[ ]

Interactive PDF forms often require users to submit their input for processing, such as sending survey results, application forms, or feedback data. A Submit Button field provides this functionality by linking the button to a web endpoint.

The FormEditor class allows adding buttons, checkboxes, radio buttons, text fields, and other form controls.

  1. Load an existing PDF document.
  2. Add a Submit Button field to a specific page.
  3. Set the button label and target submission URL.
  4. Save the updated PDF with the new button.
import sys
from os import path
import aspose.pdf.facades as pdf_facades

sys.path.append(path.join(path.dirname(__file__), ".."))

from config import set_license, initialize_data_dir


def create_submit_button(infile, outfile):
    """Create Submit Button in PDF document."""
    pdf_form_editor = pdf_facades.FormEditor()
    pdf_form_editor.bind_pdf(infile)

    # Add Submit Button to PDF form
    pdf_form_editor.add_submit_btn(
        "submitbtn1",
        1,
        "Submit Button",
        "http://example.com/submit",
        100,
        450,
        200,
        470,
    )

    # Save updated PDF document with form fields
    pdf_form_editor.save(outfile)