Rewritten to match our dependencies on pdflib 2.1.8. Some stuff is
really ugly fixes.

Never write new code using this. Just use for quick fix of old pecl
dependencies.