Thanks for all your suggestions:)
The problem with pdftk lies in the licensing of the internal itext library,
and this seems to have been solved in the latest debian (sid) where pdftk has
been patched to use the external itext library (which has no license issues).
I therefore installed the latest relevant debian sid packages by downloading
them from the debian repository (pdftk_1.41+dfsg-7_amd64.deb,
libitext-java_2.1.7-1_all.deb, libitext-java-gcj_2.1.7-1_amd64.deb, and
libitext-rups-java_2.1.7-1_all.deb).
This works fine, and I should now have a free pdftk and do not need to change
my script.
Best regards
Filologen