By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,248 Members | 1,961 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,248 IT Pros & Developers. It's quick & easy.

How do I convert word file to jpg image using com and php

P: 1
I want to make a php script when I insert doc file or pdf file in database.

At a time it generate very first image of word file or pdf.

I have seen an example related about it like:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. // starting word
  3. $word = new COM("word.application") or die("Unable to instantiate Word");
  4. echo "Loaded Word, version {$word->Version}\n";
  5.  
  6. //bring it to front
  7. $word->Visible = 1;
  8.  
  9. //open an empty document
  10. $word->Documents->Add();
  11.  
  12. //do some weird stuff
  13. $word->Selection->TypeText("This is a test...");
  14. $word->Documents[1]->SaveAs("Useless test.doc");
  15.  
  16. //closing word
  17. $word->Quit();
  18.  
  19. //free the object
  20. $word = null;
  21. ?>
  22. .this example is not working well for generate  doc file to jpg... 
  23.  
  24. but 
  25.  
  26. $powerpnt = new COM("powerpoint.application") or die("Unable to instantiate Powerpoint");
  27.  
  28. $presentation = $powerpnt->Presentations->Open(realpath($file), false, false, false) or die("Unable to open presentation");
  29.  
  30. foreach($presentation->Slides as $slide)
  31.  
  32. {
  33.  
  34.     $slideName = "Slide_" . $slide->SlideNumber;
  35.  
  36.     $exportFolder = realpath($uploadsFolder);
  37.  
  38.     $slide->Export($exportFolder."\\".$slideName.".jpg", "jpg", "600", "400");
  39.  
  40. }
  41.  
  42. $powerpnt->quit();
  43.  
  44. ?>
This script can convert ppt to jpg image ..
So my question is that how to convert doc file to jpg> Like ppt to jpg image?

Please help me.

Thanks
Jan 24 '13 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.