记下来备忘!
这是基本代码,不过还要装上openoffice才行。
<?php set_time_limit(0); 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){ $osm = new com("com.sun.star.servicemanager") or die ("please be sure that openoffice.org is installed.\n"); $args = array(makepropertyvalue("hidden",true,$osm)); $odesktop = $osm->createinstance("com.sun.star.frame.desktop"); $owriterdoc = $odesktop->loadcomponentfromurl ($doc_url,"_blank", 0, $args); $export_args = array(makepropertyvalue ("filtername","writer_pdf_export",$osm)); $owriterdoc->storetourl($output_url,$export_args); $owriterdoc->close(true); } $output_dir = "e:/word_pdf/"; $doc_file = "d:/program files/easyphp-5.3.3.1/www/mundi.ppt"; $pdf_file = "3.pdf"; $output_file = $output_dir . $pdf_file; echo $doc_file; $doc_file = "file:///" . $doc_file; $output_file = "file:///" . $output_file; word2pdf($doc_file,$output_file); ?>
