Export file as PDF

Make it a general function to export in desired format.