improved error handling for PDF files with truncated streams