Adding an image to a pdf with pdftk

Brad Hazelnut picture Brad Hazelnut · Dec 11, 2013 · Viewed 24.8k times · Source

Hello I am using pdftk to generate a PDF based on a form that is submitted.

I have everything working fine until here. Which is adding an image of a signature. I am using signature pad which works great to generate the image file of the signature. Now i am trying to add that signature image to the PDF? Does anyone know if this is even possible to do with pdftk? i don't see the option to do that. Or if its even possible to attach to the image to a form filed that i have in the PDF?

Answer

Salvi Pascual picture Salvi Pascual · Jan 13, 2014

First convert the image to PDF

convert image.png image.pdf

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

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

Then combine both PDFs using pdftk

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

You may need to download STAMPtk if you need to position the image and add it to only one page in the general PDF, but this one you have to pay for it.

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

I hope it helps!