Convert word document into 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.

Word to Images

// starting word
$word = new COM("word.application") or die("ERROR: Unable to instantiate Word");
echo "Loaded Word, version {$word->Version}\

//bring it to front
$word->Visible = 1;

//Set $FilePath and $DocFileName
$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);

//closing word

//free the object
$word = null;

PPT to Images.

<title>ShotDev.Com Tutorial</title>
    $ppApp = new COM("PowerPoint.Application");
    $ppApp->Visible = True;

  //  $strPath = realpath(basename(getenv($_SERVER["SCRIPT_NAME"]))); // C:/AppServ/www/myphp
	$strPath = "C:\\\\";
    $ppName = "Presentation.pptx";
    $FileName = "MyPP";

    //*** Open Document ***//

    //*** Save Document ***//
    $ppApp->ActivePresentation->SaveAs($strPath."/".$FileName,17);  //'*** 18=PNG, 19=BMP **'

    $ppApp = null;
PowerPoint Created to Folder <b><?=$FileName?></b>


Does the PPT to image script work? If so are there any dependencies. The COM class needs to be defined before anything will work. And even then it may only work with PowerPoint. Perhaps you could post a link to where you got the PPT to image script.


com_dotnet need to enable in php.ini file.

Following url of php mannual.

Following website for script.

Conversion between PPT and PPTX to JPG is working.

but doc and docx to JPG conversion not working.

Any Idea?


OK, so what output are you getting? Presumably you are seeing this line:

Loaded Word, version {$word->Version}\

It also looks like you are trying to save the file as “C://”

$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); // $FilePath == "C://"

I would set $FilePath to “C://Test” or something similar.

Hi mickyginger,

Your example same as my example.

Are you able to get images from word document?

I don’t have MS Word, so I can’t test the script. But you didn’t answer my question: What output/errors are you getting form your script?