将MS Word文档转换为HTML的PHP
答
查看COM extension of PHP。通过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;
?>
答
尝试使用Print2Flash获得显示原始的Word文档工作的HTML页面。这种解决方案不会丢失和保存格式,字体和图像。有人可能会得到一个有效的PHP示例,演示如何从p2f SDK中进行下载,可在此处下载:http://print2flash.com/download.php除了SDK,还需要下载和安装Print2Flash本身形成相同的页面。 PHP代码是相当简单的,最小的代码似乎是这样的:
$p2f = new COM("Print2Flash4.Server2")
$p2f->ConvertFile($sourcefile,$fsname);
也有很多你可以在这里设置附加选项。请参阅sdk的完整示例代码以了解这些选项。
请注意,在任何类型的服务器上使用无人值守的单词会引发一大堆蠕虫,因为它并非真正为此设计的。人们已经做到了。 – DarinH 2011-01-13 22:38:53