Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting MS Word document to html in php

Tags:

html

php

ms-word

How can I convert a Microsoft Word document to html in php? I am using windows, and heard that the COM package does it.

like image 207
shasi kanth Avatar asked May 08 '26 02:05

shasi kanth


1 Answers

See the COM extension of PHP.

Example of the usage by the PHP site:

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

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

//open an empty document
$word->Documents->Add();

//do some weird stuff
$word->Selection->TypeText("This is a test...");
$word->Documents[1]->SaveAs("Useless test.doc");

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

//free the object
$word = null;
?>
like image 52
powtac Avatar answered May 09 '26 17:05

powtac



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!