The place_* functions allow you to programmatically add new elements to a PDF at specific coordinates. Most of these functions require an input_pdf_path, an output_map_path (the new file generated), and a page_number.
Available Placement Functions:
place_text(text, x, y, input_pdf_path, output_map_path, page_number, font_size=12, font_name="helv", color=None): Adds raw text.place_text_box(field_name, prefilled_text, x, y, ...): Adds a text input field.place_image(file_name, x, y, input_pdf_path, output_map_path, page_number, width=10, height=10): Places an image file.place_dropdown(field_name, values, x, y, ...): Adds a dropdown menu with specific options.place_radiobutton(field_name, x, y, ...): Adds a radio button.
Coordinate System: x is the top-left corner horizontal coordinate; y is the top-right corner vertical coordinate.
from fillpdf import fillpdfs
# Place text
fillpdfs.place_text('Yo', 50, 50, 'template.pdf', 'out.pdf', 1)
# Place an image
fillpdfs.place_image('mush.png', 50, 50, 'template.pdf', 'out.pdf', 1, width=200, height=200)
# Place a dropdown
fillpdfs.place_dropdown('dropField-1', ('Berlin', 'Munich'), 0, 0, 'sample.pdf', 'out.pdf', 1, width=100, height=20)