fixed bug. Now convert to pdf file when its necessary