pdf watermarking with pdftk

Recently at work a colleague of mine needed a solution for amending a pdf. It sounds like something simple but infact he needed to apply this to multiple pdfs and be able to do it on a daily basis and teach other less computer literate people how to do it too. The reason behind this is because we use a 3rd party program for estimating and billing in our office and this system has a fixed pdf output for the invoices. These invoices are quite dull and we wanted to brand the pdf with our own logo and the vat number etc. I came up with a solution for him so that he could drag and drop multiple pdfs to a file and it would create new versions with the branding in place and saving as much of his time as possible. First off i created the following batch file

@echo off
if [%1]==[] goto :eof
pdftk %1 background back.pdf output "%~dpn1_new%~x1"
if not [%1]==[] goto loop

What this does is accept multiple files as input by dragging and dropping then it runs a command to watermark each pdf with another background pdf and output it to a new file. The part that does all the work uses an application called pdftk.exe this is a command line tool which can do a number of operations to pdfs and its a great piece free utility. You can download it from here. To do this i put my batch file, the background pdf (which is called “back.pdf”) and the program pdftk into the same folder. Heres my folder structure, to generate the new file i simple drag and drop my invoice pdf over fixpdf.bat and it will generate a new file with the same name but appended with _new.




    Comments are currently closed