php如何实现openoffice转pdf

藏色散人
풀어 주다: 2023-03-05 10:10:01
원래의
2445명이 탐색했습니다.

php openoffice转pdf的方法:首先下载“openoffice4.1.2”;然后将用户的访问权限为“允许”,并将标识调整为交互式;最后在php环境下运行代码为“function MakePropertyValue(){}”即可。

php如何实现openoffice转pdf

推荐:《PHP视频教程》 

php操作openoffice把文件转换成pdf

  1.上官网, http://www.openoffice.org。下载openoffice4.1.2

‍  2.设置权限

    cmd 运行Dcomcnfg.exe->组件服务->计算机->我的电脑->DCOM配置->OpenOffice Service Manager

  3.打开openoffice   在进程中查看打开此进程的用户是谁  然后设置此用户的访问权限为允许;

然后将标识调整为交互式;

4.在php环境下运行此代码

Bridge_GetStruct("com.sun.star.beans.PropertyValue");
    $oStruct->Name = $name;
    $oStruct->Value = $value;
    return $oStruct;
}
function word2pdf($doc_url, $output_url){
    //Invoke the OpenOffice.org service manager
        $osm = new COM("com.sun.star.ServiceManager") or die ("Please be sure that OpenOffice.org is installed.\n");
    //Set the application to remain hidden to avoid flashing the document onscreen
        $args = array(MakePropertyValue("Hidden",true,$osm));
    //Launch the desktop
        $top = $osm->createInstance("com.sun.star.frame.Desktop");
    //Load the .doc file, and pass in the "Hidden" property from above
    $oWriterDoc = $top->loadComponentFromURL($doc_url,"_blank", 0, $args);
    //Set up the arguments for the PDF output
    $export_args = array(MakePropertyValue("FilterName","writer_pdf_Export",$osm));
    //Write out the PDF
    $oWriterDoc->storeToURL($output_url,$export_args);
    $oWriterDoc->close(true);
}
$doc_file = "file:///D:/wamp/www/study/phpr/201701/11.doc";
$output_file = 'file:///D:/wamp/www/study/phpr/201701/11.pdf';
word2pdf($doc_file,$output_file);
 
?>
로그인 후 복사

注意: 易错点:

1.php首先得开启com组件

                              php5.45之前在php.ini设置com.allow_dcom = true

                              php5.45之后extension=php_com_dotnet.dll

2.doc_file和output_file路径必须严格要求为

                                file:///D:/wamp/www/study/phpr/201701/11.pdf

위 내용은 php如何实现openoffice转pdf의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

관련 라벨:
php
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
최신 이슈
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!