本篇内容介绍了“PHP怎么实现Word转PDF”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
PHP处理Word转PDF代码示例:
< ?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);
?>
“PHP怎么实现Word转PDF”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注编程网网站,小编将为大家输出更多高质量的实用文章!