Search code examples
phpms-wordphpword

Convert doc and docx to images


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();

Solution

  • 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.