added generating a preview functionality for pdf files