Move Field
Contents
[
Hide
]
PDF forms often require layout adjustments after creation. Using Aspose.PDF for Python, developers can move existing form fields to a new position without recreating them.
This example shows how to reposition the “Country” field by specifying new coordinates for its placement within the page. The FormEditor class provides the move_field method to relocate fields within a PDF page.
- Open the existing PDF form.
- Create a FormEditor object.
- Bind the PDF document to the FormEditor.
- Move the ‘Country’ field to a new position using coordinates.
- Save the modified 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 move_field(infile, outfile):
# Create FormEditor object
form_editor = pdf_facades.FormEditor()
# Bind document to FormEditor
form_editor.bind_pdf(infile)
# Move field to new page
form_editor.move_field("Country", 200, 600, 280, 620)
# Save updated document
form_editor.save(outfile)