PHP OpenOffice를 PDF로 변환하는 방법: 먼저 "openoffice4.1.2"를 다운로드한 다음 사용자의 액세스 권한을 "허용"으로 설정하고 로고를 대화형으로 조정합니다. 마지막으로 PHP 환경에서 "function MakePropertyValue(){ }"가 됩니다.

추천: "PHP 동영상 튜토리얼"
php는 파일을 pdf로 변환하는 오픈오피스를 운영하고 있습니다
1. 공식 홈페이지 http://www.openoffice.org로 이동합니다. openoffice4.1.2
다운로드 2. 권한 설정
cmd Dcomcnfg.exe->구성 요소 서비스->컴퓨터->내 컴퓨터->DCOM 구성->OpenOffice Service Manager
실행 3. 오픈오피스 열기 프로세스에서 이 프로세스를 연 사용자가 누구인지 확인한 다음 이 사용자의 액세스 권한을 허용하도록 설정하세요.
그런 다음 로고를 대화형으로 조정하세요.
4. PHP 환경에서 이 코드를 실행하세요.
<?php
/**
* Author: 宇翔大魔王
* Date: 17-1-6
* Time: 下午2:25
* TOpdf
*/
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){
//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 _com_dotnet.dll
2.doc_file 및 output_file 경로 이전에 php.ini에서 com.allow_dcom = true를 설정해야 합니다.
파일 ///D:/wamp/www/study/phpr/201701/11.pdf
위 내용은 PHP에서 오픈오피스를 PDF로 변환하는 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!