Linux under the PHP program to achieve Word file conversion to PDF file method,
In this paper, we describe how to convert Word files into PDF files under the Linux PHP program. Share to everyone for your reference, as follows:
<?phpset_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 openof Fice.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:/lighttpd/htdocs/"; $doc _file = "D:/lighttpd/htdocs/2.doc"; $pdf _file = "2.pdf"; $output _file = $output _ Dir. $pdf _file; $doc _file = "file:///". $doc _file; $output _file = "file:///". $output _file;word2pdf ($doc _file, $output _file);?
PS: If you feel that the code layout is not beautiful, small series here recommend a site of the PHP format to beautify the layout tools:
PHP Code online format beautification tool:Http://tools.jb51.net/code/phpformat
More readers interested in PHP related content can view this site topic: "PHP Operations Office Document Tips summary (including word,excel,access,ppt)", "PHP date and Time usage summary", "PHP Object-oriented Programming tutorial", "PHP string (string) Usage summary, "Getting Started with Php+mysql database operation" and "PHP common database Operation Skills Summary"
I hope this article is helpful to you in PHP programming.
http://www.bkjia.com/PHPjc/1127920.html www.bkjia.com true http://www.bkjia.com/PHPjc/1127920.html techarticle Linux under the PHP program to convert Word files into PDF file method, this article describes the Linux PHP program implementation of the Word file conversion to PDF file method. Share to everyone for reference, with ...