Using openoffice to convert the office to pdf makes the components unusable. please help me.

Source: Internet
Author: User
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; makePropertyValue converts the office to pdf using openoffice, 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!

Com component

Share:


------ 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.