php 在线浏览word paf

PHP实现Word转PDF在线预览
这篇博客介绍了如何使用PHP结合OpenOffice将其他格式的文档转换为PDF,再通过Swftool将PDF转化为SWF格式,最后利用Flexpaper加载SWF文件实现在线浏览和阅读。博主分享了初步流程,但后续详细步骤建议读者自行搜索完成。

其他格式-> Openoffice -> pdf格式
pdf格式 -> Swftool -> swf 格式
Flexpaper -> 加载 swf格式显示在线阅读

//word转pdf
function MakePropertyValue($name,$value,$osm){

    $oStruct=$osm->Bridge_GetStruct("com.sun.star.beans.PropertyValue");

    $oStruct->Name = $name;


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:/temp/test.doc";

$pdf_file = "tests.pdf";

$output_file = $output_dir.$pdf_file;

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

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

word2pdf($doc_file,$output_file);


//pdf文档转换swf
    public function pdf2swf($sourcePath,$targetPath){
        header("Content-type: text/html; charset=utf-8");
        $pdf2swf='D:/SWFTools/pdf2swf.exe';  //pdf格式转换swf格式的程序所在目录
        $argStr=$pdf2swf." -t ".$sourcePath." -s flashversion=9 ".$targetPath;
        exec($argStr,$out,$status);  //cmd执行命令
    }
}

然后用Flexpaper显示swf文件,后续步骤请百度,未进行金一步操作。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值