成人无码视频,亚洲精品久久久久av无码,午夜精品久久久久久毛片,亚洲 中文字幕 日韩 无码

資訊專欄INFORMATION COLUMN

word/excel/ppt 2 PDF

Seay / 1136人閱讀

摘要:實(shí)現(xiàn)轉(zhuǎn)換為一般最常見的就是利用來轉(zhuǎn)換,來看看實(shí)現(xiàn)的核心代碼更多詳細(xì)細(xì)節(jié)可以關(guān)注公眾號(hào),并回復(fù)獲取相關(guān)的資料。

PHP 實(shí)現(xiàn) word/excel/ppt 轉(zhuǎn)換為 PDF

一般最常見的就是利用OpenOffice來轉(zhuǎn)換,來看看實(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://m.hztianpu.com/yun/29577.html

相關(guān)文章

  • 真實(shí)體驗(yàn)迅捷PDF轉(zhuǎn)換器 PDF Word Excel PPT等格式轉(zhuǎn)換工具

    摘要:文章目錄隱藏第一迅捷轉(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)上...

    wuyangchun 評(píng)論0 收藏0
  • MongoDB ( 一 )初識(shí)

    摘要:價(jià)格目前的非關(guān)系型數(shù)據(jù)庫基本都是免費(fèi)的功能實(shí)際開發(fā)中,很多業(yè)務(wù)需求,其實(shí)并不需要完整的關(guān)系型數(shù)據(jù)庫功能,非關(guān)系型數(shù)據(jù)庫的功能就足夠使用了。目的是為應(yīng)用提供擴(kuò)展的高性能的數(shù)據(jù)存儲(chǔ)方案。我們平時(shí)大多還是使用修改器來修改下一節(jié)我們來認(rèn)識(shí)修改器 我們先來了解一下非關(guān)系型數(shù)據(jù)庫和關(guān)系型數(shù)據(jù)庫,首先需要了解一下關(guān)系型數(shù)據(jù)庫,比如,我們所熟知的 Oracle、mysql等。 關(guān)系型數(shù)據(jù)庫和非關(guān)系型數(shù)...

    NotFound 評(píng)論0 收藏0
  • nodejs(officegen)+vue(axios)在客戶端導(dǎo)出word文檔

    摘要:方式請(qǐng)求的數(shù)據(jù)只能存放在內(nèi)存空間,可以通過訪問,但是無法保存到硬盤,因?yàn)椴荒苤苯雍陀脖P交互,否則將是一個(gè)安全問題。是第一個(gè)第三方的庫,所以同理。這里是返回的對(duì)象這里表示類型創(chuàng)建下載的鏈接下載后文件名點(diǎn)擊下載下載完成移除元素釋放掉對(duì)象 前言 我的項(xiàng)目中有一個(gè)需求:點(diǎn)擊按鈕生成可編輯的word文檔訂單詳情的信息我使用的前端框架是Vue.js、后臺(tái)使用的是node.jsnode.js生成和導(dǎo)...

    Julylovin 評(píng)論0 收藏0
  • 4月份前端資源分享

    摘要:更多資源請(qǐng)文章轉(zhuǎn)自月份前端資源分享關(guān)于的思考一款有趣的動(dòng)畫效果跨站資源共享之二最流行的編程語言能做什么到底什么是閉包的第三個(gè)參數(shù)跨域資源共享詳解阮一峰前端要給力之語句在中的值周愛民中國第二屆視頻花絮編碼規(guī)范前端工程師手冊(cè)奇舞周刊被忽視的 更多資源請(qǐng)Star:https://github.com/maidishike... 文章轉(zhuǎn)自:https://github.com/jsfron...

    jsdt 評(píng)論0 收藏0

發(fā)表評(píng)論

0條評(píng)論

閱讀需要支付1元查看
<