shmem,
This isn't far off from my approach. I have some additional error handling though. Consider that the newlines are not guaranteed to be there (remember CAM::PDF omits them) and also that pp may get mistranslated. Since it doesn't have to be perfect this is fine but I am looking to improve if possible.