Fix problem when generate PDF thumbnail