Create PDF function not working