Home>Article>Backend Development> How to convert openoffice to pdf in php
php openoffice to pdf method: first download "openoffice4.1.2"; then set the user's access rights to "allow" and adjust the logo to interactive; finally run the code in the php environment as "function MakePropertyValue(){}" can be used.
Recommendation: "PHP Video Tutorial"
php operates openoffice to convert files into pdf
1. Go to the official website, http://www.openoffice.org. Download openoffice4.1.2
2. Set permissions
cmd Run Dcomcnfg.exe->Component Services->Computer->My Computer->DCOM Configuration- >OpenOffice Service Manager
3. Open openoffice and check in the process who is the user who opened this process. Then set the access permission of this user to allow;
Then adjust the logo to interactive;
4. Run this code in the php environment
Bridge_GetStruct("com.sun.star.beans.PropertyValue"); $oStruct->Name = $name; $oStruct->Value = $value; return $oStruct; } function word2pdf($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(MakePropertyValue("Hidden",true,$osm)); //Launch the desktop $top = $osm->createInstance("com.sun.star.frame.Desktop"); //Load the .doc file, and pass in the "Hidden" property from above $oWriterDoc = $top->loadComponentFromURL($doc_url,"_blank", 0, $args); //Set up the arguments for the PDF output $export_args = array(MakePropertyValue("FilterName","writer_pdf_Export",$osm)); //Write out the PDF $oWriterDoc->storeToURL($output_url,$export_args); $oWriterDoc->close(true); } $doc_file = "file:///D:/wamp/www/study/phpr/201701/11.doc"; $output_file = 'file:///D:/wamp/www/study/phpr/201701/11.pdf'; word2pdf($doc_file,$output_file); ?>
Note: Error-prone points:
1.php must first open the com component
php5. Before 45, set com.allow_dcom = true
in php.ini. file :///D:/wamp/www/study/phpr/201701/11.pdf
The above is the detailed content of How to convert openoffice to pdf in php. For more information, please follow other related articles on the PHP Chinese website!