Convert word document into images

Hi,

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


<?php
// 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);
$word->Documents[1]->Close();

//closing word
$word->Quit();

//free the object
$word = null;
?>

PPT to Images.


<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<?
    $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 ***//
    $ppApp->Presentations->Open(realpath($ppName));

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

    $ppApp->Quit;
    $ppApp = null;
?>
PowerPoint Created to Folder <b><?=$FileName?></b>
</body>
</html>

-Thanks

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.

Hi,

com_dotnet need to enable in php.ini file.

Following url of php mannual.

http://us2.php.net/manual/en/class.com.php

Following website for script.

http://www.shotdev.com/php/php-com-powerpoint/php-powerpoint-export-convert-ppt-to-jpg-and-send-email-attachment/

Conversion between PPT and PPTX to JPG is working.

but doc and docx to JPG conversion not working.

Any Idea?

-Thanks

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://"
$word->Documents[1]->Close();

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?