PDF coordinate system⚓︎
The PDF coordinate system originates at the bottom left of the page. The unit of measurement is "points," with 72 points per inch. PyPDFForm uses this coordinate system when creating fields, text, and images on a PDF.
Generate a coordinate grid view⚓︎
To make PDF coordinates easier to work with, PyPDFForm provides a grid view that helps you determine the optimal placement of elements on a PDF.
To generate a coordinate grid view for this PDF:
Use the PdfWrapper.generate_coordinate_grid method:
from PyPDFForm import PdfWrapper
grid_view_pdf = PdfWrapper("sample_template.pdf").generate_coordinate_grid(
color=(1, 0, 0), # optional
margin=100 # optional
)
grid_view_pdf.write("output.pdf")
The generate_coordinate_grid method accepts two optional parameters: color and margin. The color parameter sets the grid color (defaulting to red), and the margin parameter sets the grid margin in points (defaulting to 100 points).
Inspect form field locations & dimensions⚓︎
You can inspect the location and dimensions of a PDF form field's rectangular bounding box by accessing its widget object:
Change form field coordinates & dimensions⚓︎
Tip
For a checkbox or radio button, consider modifying size instead of width or height.
You can modify these same attributes to reposition or resize the field's rectangular bounding box: