Just a few documents, you could 'print' each to a pdf, then use your routine to make the thumbnail. Linux/Mac has 'make a pdf' but I don't know about PHP. I use 'CutePDFmaker' on the PC, which uses ghostscript and a 'pdf' printer to convert anything to pdf.