Proper handling of multipage pdfs