Using openoffice to convert the office into a pdf file makes the component unusable. please help me. At the end of this post, nationzhou edited php & nbsp in 2013-05-1816: 42: 24; converted the office into pdf format using openoffice & nbsp; the following code is provided: function & nbsp; makePro uses openoffice to convert office to pdf, and components cannot be used. please help me.
This post was last edited by nationzhou at 16:42:24
Php converts an office to a pdf file using openoffice.
The code is as follows:
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 = "D:/APMServ5.2.6/www/htdocs/pdf/";
$doc_file = "D:/APMServ5.2.6/www/htdocs/doc/abc.doc";
$pdf_file = "abc.pdf";
$output_file = $output_dir . $pdf_file;
$doc_file = "file:///" . $doc_file;
$output_file = "file:///" . $output_file;
word2pdf($doc_file,$output_file);
Error message:
Fatal error: Uncaught exception 'com _ exception' with message 'failed' to create com object' COM. sun. star. serviceManager ': server running failed' in D: \ APMServ5.2.6 \ www \ htdocs \ phpinfo. php: 13 Stack trace: #0 D: \ APMServ5.2.6 \ www \ htdocs \ phpinfo. php (13): com-> com ('com. sun. star. se... ')
System environment: apache, php5.2.6, and php. ini have enabled com, dcom,
Operating system: win2003. OpenOffice3.2 has been installed, and access permissions for components related to openoffice have been set,
Start the OpenOffice service using the command line:
Cd C: \ Program Files \ OpenOffice.org 3 \ program
C: \ Program Files \ OpenOffice.org 3 \ program> soffice-headless-accept = "socket, host = 127.0.0.1, port = 8100; urp;"-nofirststartwizard
The page is still inaccessible. It takes about one minute to run and the above error is prompted. thank you!
------ Solution --------------------
He has already told you that creating the com. sun. star. ServiceManager service has failed.
This is irrelevant to php.
You need to first check whether your software works normally, that is, whether it can be switched in openoffice
If yes, check whether the COM + service is started.