Search code examples
phplinuxshellthumbnailsphpthumb

PDF Thumbnail shell command problem - PHP


I have a set of 1000 pdf in my server. Now, i want to create a thumbnail for each pdf. The PDF NAME include spaces and special characters(This is a joomla component - Docman, So i could not customize this component to create a file name without spaces and special characters). I am using shell command to generate the thumbnail for each pdf. My code is :

 $pdf_name = "/home/jaff/project/dmdocuments/Test's Document.pdf"    
 "convert -thumbnail 200x260 /home/jaff/project1/dmdocuments/".$new_name1."[0] /home/jaff/project1/images/".$pdf_name.".png"

I can generate thumbnail for pdf if the pdf file name does not contain spaces and special characters.

Now, is it possible to create thumbnail using space and special characters for pdf file name without ALTERING the pdf file name in my dmdocuments folder ? Or any other shell command, to rename the file name in dmdocuments folder and after creating thumbnail, again rename it to its original file name??

Thanks - Haan


Solution

  • That should be possible by quoting the file path.

    "convert -thumbnail 200x260 \"/home/jaff/project1/dmdocuments/".$new_name1."[0]\" \"/home/jaff/project1/images/".$pdf_name.".png\""