1) $pdf is an PDF::API2-object that is created outside the subroutine as a package-global.
2) I donīt consider globals to be bad in short scripts. I am using strict, but i did post only the relevant subroutine.
3) The same thing. The error does not relate to the number of documents.
4) I will update my code-section.