The method of translating the Word file into PDF file under Linux php _php skill

Source: Internet
Author: User
Tags php database

This article describes the Linux PHP program to achieve the conversion of Word files to PDF files. Share to everyone for your reference, specific as follows:

<?php set_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; The function word2pdf ($doc _url, $output _url) {$osm = new COM ("Com.sun.star.ServiceManager") or Die ("Please be sure that Ope
Noffice.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 landscaping layout tools:

PHP Code online Format Landscaping tool:Http://tools.jb51.net/code/phpformat

For more information on PHP-related content readers can view the site topics: "PHP operation Office Document tips summary (including word,excel,access,ppt)", "PHP date and Time usage summary", "PHP object-oriented Program Design Introductory Course", "PHP string (string) Summary of usage, Getting Started tutorial on Php+mysql database operations, and summary of common PHP database operations techniques

I hope this article will help you with the PHP program design.

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.