php ppt如何转换成pdf,PHP将Word,Wps,Excel,PPT转成PDF

PHP将Word,Wps,Excel,PPT转成PDF

作者:super 时间:2016-04-05 17:16:14

EXCEL部分:

set_time_limit(10);

echo "开始
";

$et = new COM("ET.Application");

echo "打开COM接口
";

$path_parts=pathinfo(__FILE__);

$dir=$path_parts["dirname"]."";

$src_filename = $dir."1.xls";  //源文件,et或者xls都可以

$dest_filename = $dir."1.new.xls"; //另存为的文件名

$pdf_filename = $dir."1.xls.pdf"; //欲转PDF的文件名

$wb = $et->Workbooks->Open($src_filename);

echo "成功打开文件
";

//echo "输出文件中数据".$wb->Path."
";

$wb->SaveAs($dest_filename);

echo "另存为操作
";

$wb->exportpdf($pdf_filename);

echo "转成PDF
";

$wb->Close();

echo "关闭WorkBooks
";

$et->Quit();

echo "关闭COM
";

unset( $wb , $et );

echo "回收资源
";

?>

PPT部分

//set_time_limit(10);

echo "开始
";

$wpp = new COM("WPP.Application"); //转wps的话,用WPS

echo "打开COM接口
";

$dir="F:HTDOCSz11";

$src_filename=$dir."111.ppt"; //源文件,DOC或者WPS都可以

$dest_filename=$dir."111.dps"; //另存为的文件名

$pdf_filename=$dir."doc22.pdf"; //欲转PDF的文件名

$pre = $wpp->Presentations->Open($src_filename);//转wps的话,用Documents

echo "成功打开文件
";

echo "输出文件中数据".$pre->Path."
";

$pre->SaveAs($dest_filename);

echo "另存为操作
";

$pre->exportpdf($pdf_filename);

echo "转成PDF
";

$pre->Close();

echo "关闭Presentations
";

$wpp->Quit();

echo "关闭COM
";

unset( $pre , $wpp );

echo "回收资源
";

?>

WORD部分

";

$wps = new COM("WPS.Application");echo "打开COM接口
";

$src_filename="D:

etworkhtdocsest1.doc"; //源文件,DOC或者WPS都可以$dest_filename="D:

etworkhtdocsestdoc2.wps"; //另存为的文件名$pdf_filename="D:

etworkhtdocsestdoc2.pdf"; //欲转PDF的文件名

$doc = $wps->Documents->Open($src_filename);echo "成功打开文件
";echo "输出文件中数据:
".$doc->content."
";

$doc->SaveAs($dest_filename);echo "另存为操作
";

$doc->exportpdf($pdf_filename);echo "转成PDF
";

$doc->Close();echo "关闭Document
";

$wps->Quit();echo "关闭COM
";

unset( $doc , $wps );echo "回收资源
";?>

分享到:

<< 上一篇:JS显示30天有效日历 (2016-05-24 00:21)

>> 下一篇:我是一颗野草 (2016-03-29 10:11)

你可能感兴趣的:(php,ppt如何转换成pdf)