How to convert Word files into PDF files under the Linux PHP program, _php Tutorial

Source: Internet
Author: User
Tags getting started with php

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

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