摘要:實(shí)現(xiàn)轉(zhuǎn)換為一般最常見(jiàn)的就是利用來(lái)轉(zhuǎn)換,來(lái)看看實(shí)現(xiàn)的核心代碼更多詳細(xì)細(xì)節(jié)可以關(guān)注公眾號(hào),并回復(fù)獲取相關(guān)的資料。
PHP 實(shí)現(xiàn) word/excel/ppt 轉(zhuǎn)換為 PDF
一般最常見(jiàn)的就是利用OpenOffice來(lái)轉(zhuǎn)換,來(lái)看看實(shí)現(xiàn)的核心代碼:
class PDFConverter { private $com; /** * need to install openoffice and run in the background * soffice -headless-accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard */ public function __construct() { try { $this->com = new COM("com.sun.star.ServiceManager"); } catch (Exception $e) { die("Please be sure that OpenOffice.org is installed."); } } /** * Execute PDF file(absolute path) conversion * @param $source [source file] * @param $export [export file] */ public function execute($source, $export) { $source = "file:///" . str_replace("", "/", $source); $export = "file:///" . str_replace("", "/", $export); $this->convertProcess($source, $export); } /** * Get the PDF pages * @param $pdf_path [absolute path] * @return int */ public function getPages($pdf_path) { if (!file_exists($pdf_path)) return 0; if (!is_readable($pdf_path)) return 0; if ($fp = fopen($pdf_path, "r")) { $page = 0; while (!feof($fp)) { $line = fgets($fp, 255); if (preg_match("http://Count [0-9]+/", $line, $matches)) { preg_match("/[0-9]+/", $matches[0], $matches2); $page = ($page < $matches2[0]) ? $matches2[0] : $page; } } fclose($fp); return $page; } return 0; } private function setProperty($name, $value) { $struct = $this->com->Bridge_GetStruct("com.sun.star.beans.PropertyValue"); $struct->Name = $name; $struct->Value = $value; return $struct; } private function convertProcess($source, $export) { $desktop_args = array($this->setProperty("Hidden", true)); $desktop = $this->com->createInstance("com.sun.star.frame.Desktop"); $export_args = array($this->setProperty("FilterName", "writer_pdf_Export")); $program = $desktop->loadComponentFromURL($source, "_blank", 0, $desktop_args); $program->storeToURL($export, $export_args); $program->close(true); } }
更多詳細(xì)細(xì)節(jié)可以關(guān)注公眾號(hào),并回復(fù) word 獲取word相關(guān)的資料。
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請(qǐng)注明本文地址:http://www.ezyhdfw.cn/yun/29577.html
摘要:文章目錄隱藏第一迅捷轉(zhuǎn)換器的版本介紹第二迅捷轉(zhuǎn)換器的功能體驗(yàn)第一迅捷轉(zhuǎn)換器的版本介紹老蔣有看到,迅捷轉(zhuǎn)換器的版本有多個(gè)版本。而且老蔣有在體驗(yàn)這款迅捷轉(zhuǎn)換軟件的時(shí)候,速度確實(shí)提高不少,那種在線轉(zhuǎn)換的時(shí)候速度特別慢。由于工作的需要,我們很多網(wǎng)友朋友可能會(huì)希望將PDF文件格式轉(zhuǎn)換成Word、PPT、TXT 或者 Excel等格式。我們一般是用什么軟件操作的呢?比如老蔣每次遇到這樣的需求,就會(huì)找網(wǎng)上...
摘要:價(jià)格目前的非關(guān)系型數(shù)據(jù)庫(kù)基本都是免費(fèi)的功能實(shí)際開(kāi)發(fā)中,很多業(yè)務(wù)需求,其實(shí)并不需要完整的關(guān)系型數(shù)據(jù)庫(kù)功能,非關(guān)系型數(shù)據(jù)庫(kù)的功能就足夠使用了。目的是為應(yīng)用提供擴(kuò)展的高性能的數(shù)據(jù)存儲(chǔ)方案。我們平時(shí)大多還是使用修改器來(lái)修改下一節(jié)我們來(lái)認(rèn)識(shí)修改器 我們先來(lái)了解一下非關(guān)系型數(shù)據(jù)庫(kù)和關(guān)系型數(shù)據(jù)庫(kù),首先需要了解一下關(guān)系型數(shù)據(jù)庫(kù),比如,我們所熟知的 Oracle、mysql等。 關(guān)系型數(shù)據(jù)庫(kù)和非關(guān)系型數(shù)...
摘要:方式請(qǐng)求的數(shù)據(jù)只能存放在內(nèi)存空間,可以通過(guò)訪問(wèn),但是無(wú)法保存到硬盤(pán),因?yàn)椴荒苤苯雍陀脖P(pán)交互,否則將是一個(gè)安全問(wèn)題。是第一個(gè)第三方的庫(kù),所以同理。這里是返回的對(duì)象這里表示類(lèi)型創(chuàng)建下載的鏈接下載后文件名點(diǎn)擊下載下載完成移除元素釋放掉對(duì)象 前言 我的項(xiàng)目中有一個(gè)需求:點(diǎn)擊按鈕生成可編輯的word文檔訂單詳情的信息我使用的前端框架是Vue.js、后臺(tái)使用的是node.jsnode.js生成和導(dǎo)...
摘要:更多資源請(qǐng)文章轉(zhuǎn)自月份前端資源分享關(guān)于的思考一款有趣的動(dòng)畫(huà)效果跨站資源共享之二最流行的編程語(yǔ)言能做什么到底什么是閉包的第三個(gè)參數(shù)跨域資源共享詳解阮一峰前端要給力之語(yǔ)句在中的值周愛(ài)民中國(guó)第二屆視頻花絮編碼規(guī)范前端工程師手冊(cè)奇舞周刊被忽視的 更多資源請(qǐng)Star:https://github.com/maidishike... 文章轉(zhuǎn)自:https://github.com/jsfron...
閱讀 1938·2021-08-13 15:06
閱讀 3182·2021-08-05 10:02
閱讀 3475·2019-08-30 15:55
閱讀 2472·2019-08-30 13:46
閱讀 2569·2019-08-30 13:01
閱讀 1407·2019-08-29 17:17
閱讀 2886·2019-08-29 15:27
閱讀 1493·2019-08-29 11:12