Adding an image to pdf using pdftk

Hello, I am using pdftk to create a PDF based on the form that is submitted.

Everything works fine for me while here. What adds a signature image. I use a signature that works great for creating a signature image file. Now I'm trying to add this signature image to a PDF? Does anyone know if this is possible with pdftk? I see no way to do this. Or if it can even be attached to the image in the form registered in the PDF?

+7
php pdf-generation pdftk
source share
2 answers

Convert image to PDF first

convert image.png image.pdf 

Then scale and shift the image using pdfjam (another free tool)

 pdfjam --paper 'a4paper' --scale 0.3 --offset '7cm -12cm' image.pdf 

Then merge both pdfs using pdftk

 pdftk text.pdf stamp image.pdf output combined.pdf 

You may need to download STAMPtk if you need to put an image and add it only on one page in a common PDF file, but you have to pay for it.

You can download STAMPtk here http://www.pdflabs.com/tools/stamptk-the-pdf-stamp-maker/

Hope this helps!

+24
source share

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.

0
source share

All Articles