Fixed pdf generation bug