Home >Backend Development >PHP Tutorial >How to convert WORD files into PDF files using PHP program under LINUX, _PHP tutorial

How to convert WORD files into PDF files using PHP program under LINUX, _PHP tutorial

WBOY
WBOYOriginal
2016-07-12 08:51:56882browse

The method of converting WORD files into PDF files by PHP program under LINUX,

This article describes the method of converting WORD files into PDF files by PHP program under LINUX. Share it with everyone for your reference, the details are as follows:

<&#63;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;
}
function word2pdf($doc_url, $output_url){
$osm = new COM("com.sun.star.ServiceManager") or die ("Please be sure that 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:/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);
&#63;>

PS: If you feel that the code layout is not beautiful enough, the editor here recommends a php formatting and beautifying typesetting tool for this website:

PHP code online formatting and beautification tool: http://tools.jb51.net/code/phpformat

Readers who are interested in more PHP-related content can check out the special topics of this site: "Summary of PHP office document operation skills (including word, excel, access, ppt)", "Summary of PHP date and time usage", "php-oriented "Introduction Tutorial on Object Programming", "Summary of PHP String Usage", "Introduction Tutorial on PHP MySQL Database Operation" and "Summary of Common PHP Database Operation Skills"

I hope this article will be helpful to everyone in PHP programming.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1127920.htmlTechArticleHow to convert WORD files into PDF files by PHP program under LINUX. This article describes the example of realizing WORD by PHP program under LINUX. How to convert files into PDF files. Share it with everyone for your reference, with...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn