Improved PDF handling