繁体   English   中英

在MS中将MS Word文档转换为html

[英]Converting MS Word document to html in php

如何在PHP中将Microsoft Word文档转换为html? 我正在使用Windows,并听说COM包就可以了。

请参阅PHPCOM扩展

PHP站点的使用示例:

<?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的完整示例代码以了解这些选项。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM