Use OpenOffice to turn office into PDF, the component is not available, please help

Source: Internet
Author: User
Use OpenOffice to convert Office to PDF, the components can not be used, please heroes help.
This post was last edited by Nationzhou on 2013-05-18 16:42:24

PHP uses OpenOffice to turn office into PDF format questions to ask
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 ("Sure this 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 ': Service The service failed ' in D:\apmserv5.2.6\www\htdocs\phpinfo.php:13 Stack trace: #0 D:\APMServ5.2.6\www\htdocs\phpinfo.php: com- >com (' Com.sun.star.Se ... ')

System environment: Apache, php5.2.6, PHP.ini has opened com,dcom,
Operating system: Win2003, OpenOffice3.2 has been installed, access to OpenOffice related components has been set,
Started the OpenOffice service with 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

Still cannot access, page probably run a minute to prompt above error, Hope Warrior can help solve, thanks!
------Solution--------------------
He already told you that the creation of the Com.sun.star.ServiceManager service failed.
This is not related to PHP.

You need to verify that your software is working properly, that you can convert it in OpenOffice
If it succeeds, check to see if COM + services are started
  • Related Article

    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.