4

I'm uploading some files (pdf, doc, docx, ppt, pptx) etc.

For previewing purpose, I want to grab a thumbnail screenshot of the content of the first page of these files.

How can I achieve this using PHP (or JavaScript)?

ptamzz
  • 9,235
  • 31
  • 91
  • 147
  • 6
    Wow, be prepared to suffer. – Darin Dimitrov Jan 08 '12 at 19:55
  • Is that kind of impossible or something? Any work around? – ptamzz Jan 08 '12 at 19:57
  • 1
    Possible duplicate: http://stackoverflow.com/questions/7708534/create-a-thumbnail-preview-of-documents-pdf-doc-xls-etc-in-php-lamp – Jeremy Harris Jan 08 '12 at 19:58
  • No, there are no impossible things. It's just that this will require quite a lot of work. Work that's probably already done by someone (not familiar with PHP) but you will have to prepare yourself to pay money because as I said it's a lot of work, especially if you want to do this in a reliable manner and handle many concurrent users. – Darin Dimitrov Jan 08 '12 at 19:58
  • What OS is your host running on? If it is on Windows there are some aftermarket tools that do this (we use them at my work). If you are on Linux then doc and ppt are probably going to be difficult. – mrtsherman Jan 08 '12 at 19:58
  • @mrsherman: I'm on a Linux environment. – ptamzz Jan 08 '12 at 20:03
  • 1
    Well I get the general idea from @cillosis 's link above. Ok Thanks everyone. – ptamzz Jan 08 '12 at 20:03

1 Answers1

0

For Excel, Word & Presentation you can use https://github.com/PHPOffice

For PDF you can use Imagick. Use [0] to make a screenshot of the fist page. https://medium.com/@freekmurze/convert-a-pdf-to-an-image-using-php-dfa8e2a921bd

Sarah Trees
  • 822
  • 12
  • 28