0

I want to convert word documents into images. Each page in word document will be converted into images. I found following example and it converts ppt file into image. I found word to image convertor script in php but it is not working , I am getting no output after executing page. I also tried phpword to convert word file to pdf and then get images by using imagick but in the phpword i didn't get images(inside word file) data. i get only text in the coverted pdf file. I tried so many ways but didn't get any solution. Anyone can help me to found any way or solution?

$word = new COM("word.application") or die("ERROR: Unable to instantiate Word");
echo "Loaded Word, version {$word->Version}";
$word->Visible = 1;
$FilePath = "C:\\\\";
$DocFilename = "Sample.docx";
$stat = $word->Documents->Open(realpath("$DocFilename")) or die ("ERROR: Could not open Word Doc");
$word->Documents[1]->SaveAs("$FilePath", 17);
$word->Documents[1]->Close();
Cindy Meister
  • 25,071
  • 21
  • 34
  • 43
  • this question is already answered: https://stackoverflow.com/questions/5538584/convert-word-doc-docx-and-excel-xls-xlsx-to-pdf-with-php – David Shindler Feb 06 '20 at 12:37
  • i need images of each page of the word file? – Vikas Rathor Feb 06 '20 at 12:42
  • Do you see any errors while executing your script? You also need to remove doublequotes from variables, "$DocFilename" for example. – David Shindler Feb 06 '20 at 12:46
  • Fatal error: Uncaught com_exception: Source: Microsoft Word
    Description: The file appears to be corrupted. in D:\wamp64\www\Projects\sbaski.com\php_ppt_to_mail\php_ppt_to_mail.php on line 14 ( ! ) com_exception: Source: Microsoft Word
    Description: The file appears to be corrupted. in D:\wamp64\www\Projects\sbaski.com\php_ppt_to_mail\php_ppt_to_mail.php on line 14
    – Vikas Rathor Feb 06 '20 at 12:58
  • Did you try another file? – David Shindler Feb 06 '20 at 12:59
  • Yes i tried anthor docx file which is already in same folder where the script is working – Vikas Rathor Feb 06 '20 at 13:02
  • One would assume the error is on the line that tries to open the document? If yes, can the document be opened in Word when you try as a user, or does the error message also display? – Cindy Meister Feb 06 '20 at 14:29
  • Yes but how can i get images of each page with the help of php script? – Vikas Rathor Feb 07 '20 at 04:57

1 Answers1

0

Now i am using libreOffice on the live server for convert doc , docx , ppt , pptx to pdf and then use of imagick to get my images.