Catching exception when pdf corrupted