Fixes #509 out of memory when generating huge pdf files. with ruby 1.8 fallback