To appease the utterly evil, capricious and monstrous gods of Italian bureaucracy, I needed to craft several PDF files to sacrifice to the altar of the Italian Certified Email.
Three of those PDFs (let's call them A.pdf
, B.pdf
and C.pdf
) are copies
of multi-page PDFs where I need to sign each page and then send them back.
One of them (let's say C.pdf
) needs to be signed on each page except the
last, which needs instead to be signed twice in two special blank spaces.
I have a transparent png
with my signature (let's call it signature.png
).
Let's start with C.pdf
:
# Split C.pdf into single-page PDFs
pdftk C.pdf burst
# Edit a random page in inkscape, add a signature to the corner of the
# page, delete the rest of the contents and save as signature.pdf
inkscape pg_0001.pdf
# Edit the last page in inkscape, add the signatures where needed, save
# as pg_0005-signed.pdf
inkscape pg_0005.pdf
# Stamp the signatures all over all pages but the last one
for f in pg_000[1-4].pdf
do
pdftk $f stamp signature.pdf output `basename $f .pdf`-signed.pdf
done
# Put it all together
pdftk pg_000*-signed.pdf cat output C-signed.pdf
And now that I have signature.pdf
, I can easily process A
and B
:
pdftk A.pdf stamp signature.pdf output A-signed.pdf
pdftk B.pdf stamp signature.pdf output B-signed.pdf
pdftk
is much smarted than that, and it would have been able to extract a
single document with all pages of C.pdf
except the last one, but with Italian
bureaucracy it is painful enough to get the job done that afterwards one is
more likely to need eating chocolate to avoid depression, rather than to try
and redo it all again more elegantly.
So, there are times when bureaucracy calls for printing a pile of sheets, mindlessly sign them all, scan them again, shred them, plant a new tree, and then finally book a MRI scan of your wrist to assess the state of your carpal tunnel.