思想:将word之类的文件先用openoffice转为pdf,再将pdf文件通过swftools转为swf文件,最后通过Flexpaper展示在页面上
第一步:
首先需安装OpenOffice,并注册com组件(方法可以百度到),接着可以运行代码:
<?php
function MakePropertyValue($name,$value,$osm){
$oStruct = $osm->Bridge_GetStruct("com.sun.star.beans.PropertyValue");
$oStruct->Name = $name;
$oStruct->Value = $value;
return $oStruct;
}
function word2pdf($doc_url, $output_url){
//Invoke the http://OpenOffice.org service manager
$osm = new COM("com.sun.star.ServiceManager") or die ("Please be sure that http://OpenOffice.org is installed.\n");
//Set the application to remain hidden to avoid flashing the document onscreen
$args = array(MakePropertyValue("Hidden",true,$osm));
//Launch the desktop
$top = $osm->createInstance("com.sun.star.frame.Desktop");
//Load the .doc file, and pass in the "Hidden" property from above
$oWriterDoc = $top->loadComponentFromURL($doc_url,"_blank", 0, $args);
//Set up the arguments for the PDF output
$export_args = array(MakePropertyValue("FilterName","writer_pdf_Export",$osm));
//Write out the PDF
$oWriterDoc->storeToURL($output_url,$export_args);
$oWriterDoc->close(true);
}
$doc_file = "file:///f:/2.doc"; //此路径比较重要,一般出问题比较多
$output_file = 'file:///f:/3.pdf'; //此路径比较重要,一般出问题比较多
word2pdf($doc_file,$output_file);
?>
第二步:安装swftools,并调用命令行(注意加上-s flashversion=9,否则在flexpaper可能展示不出来)
第三步,下载flexpaper,直接将转过后的swf路径加载进去,即可完美展示。