簡體   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