色婷婷狠狠18禁久久YY,CHINESE性内射高清国产,国产女人18毛片水真多1,国产AV在线观看

如何把word格式轉換成php?

錢艷冰2年前15瀏覽0評論

PHP也可以實現導出Word文檔為PDF的功能,不過要借助于第三方的類庫,今天我們將為大家介紹PHP依靠com.sun.star.ServiceManager來轉換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 ("請確認OpenOffice.org庫是否已經安裝.\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:/temp/";

$doc_file = "D:/temps/test.doc";

$pdf_file = "test.pdf";

$output_file = $output_dir.$pdf_file;

$doc_file = "file:///".$doc_file;

$output_file = "file:///".$output_file;

word2pdf($doc_file,$output_file);

?>