pdfjinja for Python
https://github.com/rammie/pdfjinja
This library will allow you to add images to the signature object or buttons in your PDF file without the need for merging or location information.
1. Add a signature element to your PDF template
Adobe Pro lets you create and modify fillable PDF forms. Go to Tools> Forms> Edit, then select Digital Signature from the Add New Field drop-down menu.
Once placed, go to the properties of the Digital Signature element. In the Tooltip property add
{{ Sig | paste }}
Save and close.
2. Save the signature image in jpg or png format
You may need a separate method for extracting image captions and placing them in an accessible folder.
3. Add a method to your Python script
from pdfjinja import PdfJinja pdf_jinja_object = PdfJinja("path_to_pdf_template") filled_out_pdf = pdf_jinja_object({ 'firstName': 'John', 'lastName': 'Smith', 'sig': 'path_to_pdf_template', }) filled_out_pdf.write(open("output_file.pdf", 'wb'))
This should provide you with a form with your signature image located in the place created in your template.
Jeremy swagger
source share