<?php
function OpenOfficeMakePropertyValue( $name, $value, $osm)
{
$oStruct = $osm->Bridge_GetStruct("com.sun.star.beans.PropertyValue");
$oStruct->Name = $name;
$oStruct->Value = $value;
return $oStruct;
}
function OpenOfficeWordToHtml( $doc_url, $output_url )
{
//Invoke the OpenOffice.org service manager
$osm = new COM("com.sun.star.ServiceManager") or die ("Please be sure that OpenOffice.org is installed.\n");
//Set the application to remain hidden to avoid flashing the document onscreen
$args = array(OpenOfficeMakePropertyValue("Hidden",true,$osm));
//Launch the desktop
$oDesktop = $osm->createInstance("com.sun.star.frame.Desktop");
//Load the .doc file, and pass in the "Hidden" property from above
$oWriterDoc = $oDesktop->loadComponentFromURL($doc_url,"_blank", 0, $args);
//Set up the arguments for the PDF output
$export_args = array(
OpenOfficeMakePropertyValue("FilterName","HTML (StarWriter)",$osm) ,
OpenOfficeMakePropertyValue("Overwrite","true",$osm)
);
//Write out the HTML
$oWriterDoc->storeToURL($output_url,$export_args);
$oWriterDoc->close(true);
}
$output_dir = "文件导出的目录,如F:/";
$doc_file = "doc文件的位置,如F:/test.doc";
$pdf_file = "导出html文件的名字,如test.html";