内射老阿姨1区2区3区4区_久久精品人人做人人爽电影蜜月_久久国产精品亚洲77777_99精品又大又爽又粗少妇毛片

怎么在PHP中利用Xpdf讀取PDF的內(nèi)容-創(chuàng)新互聯(lián)

這篇文章給大家介紹怎么在PHP中利用Xpdf讀取PDF的內(nèi)容,內(nèi)容非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對(duì)大家能有所幫助。

目前成都創(chuàng)新互聯(lián)已為上千多家的企業(yè)提供了網(wǎng)站建設(shè)、域名、虛擬空間、網(wǎng)站托管、企業(yè)網(wǎng)站設(shè)計(jì)、鼓樓網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長(zhǎng),共同發(fā)展。

一.下載
首先,我們先把資料下下來先。
如果不需要轉(zhuǎn)中文的話,只需要下載它就可以:xpdf-bin-linux-3.03.tar,如果需要轉(zhuǎn)中文,那你就還需要它了:xpdf-chinese-simplified.tar
二.安裝
現(xiàn)在,下載完畢了吧,我們可以進(jìn)行安裝了。
[root@localhost ~]# mkdir -p /lcf/upan
[root@localhost ~]# mkdir -p /lcf/cdrom
[root@localhost ~]# mkdir -p /lcf/xpdf
[root@localhost ~]# cd /lcf/upan/
[root@localhost upan]# cp xpdf/* ../xpdf/ (下載的文件放入/lcf/xpdf目錄)
[root@localhost upan]# cd ../xpdf/
[root@localhost xpdf]# tar -zxvf xpdfbin-linux-3.03.tar.gz
[root@localhost xpdf]# cd xpdfbin-linux-3.03
[root@localhost xpdfbin-linux-3.03]# cat INSTALL
[root@localhost xpdfbin-linux-3.03]# cd bin32/
[root@localhost bin32]# cp ./* /usr/local/bin/
[root@localhost bin32]# cd ../doc/
[root@localhost doc]# mkdir -p /usr/local/man/man1
[root@localhost doc]# mkdir -p /usr/local/man/man5
[root@localhost doc]# cp *.1 /usr/local/man/man1
[root@localhost doc]# cp *.5 /usr/local/man/man5
如果不需要讀取中文的話,到這里就可以結(jié)束了,如果需要,那我們繼續(xù)往后
[root@localhost doc]# cp sample-xpdfrc /usr/local/etc/xpdfrc
[root@localhost xpdf]# cd /lcf/xpdf
[root@localhost xpdf]# tar -zxvf xpdf-chinese-simplified.tar.gz
[root@localhost xpdf]# cd xpdf-chinese-simplified
[root@localhost xpdf]# mkdir -p/usr/local/share/xpdf/chinese-simplified
[root@localhost xpdf]# cd xpdf-chinese-simplified/
[root@localhost xpdf-chinese-simplified]# cp Adobe-GB1.cidToUnicode ISO-2022-CN.unicodeMap EUC-CN.unicodeMap GBK.unicodeMap CMAP /usr/local/share/xpdf/chinese-simplified/
把chinese-simplified里面文件add-to-xpdfrc 的內(nèi)容復(fù)制到/usr/local/etc/xpdfrc文件中。記得里面的路徑要正確。(注意,這里面的簡(jiǎn)體中文包包括以下三種格式:ISO-2022-CN,EUC-CN,GBK ,看清楚哦,不支持UTF-8,可以先轉(zhuǎn)為GBK,然后進(jìn)行轉(zhuǎn)義)

三.功能實(shí)現(xiàn)
至此,所有的配置完畢,我們要開始使用它了。
如果是簡(jiǎn)單的PDF讀取,那么直接用下面的語句就OK了。
$content = shell_exec('/usr/local/bin/pdftotext '.$filename.' -');
如果需要轉(zhuǎn)中文,如此這般,加上參數(shù)。
$content = shell_exec('/usr/local/bin/pdftotext -layout -enc GBK '.$filename.' -');
當(dāng)然,加了參數(shù)之后依然是不影響英文的轉(zhuǎn)換的,所以,放心使用吧。需要注意的是,這里轉(zhuǎn)出來的是GBK編碼的哦,現(xiàn)在網(wǎng)站很多用的是UTF-8,想要不顯示亂碼的話,需要再次轉(zhuǎn)義一下哦。
$content = mb_convert_encoding($content, 'UTF-8','GBK');
至此,就大功告成了。讀取出來的內(nèi)容,你想如何使用,再寫代碼處理吧。
最后加一下pdftotext 的參數(shù)說明給大家。

主要參數(shù)如下:
OPTIONS
Many of the following options can be set with configuration file com-
mands. These are listed in square brackets with the description of the
corresponding command line option.
-f number
Specifies the first page to convert.
-l number
Specifies the last page to convert.
-layout
Maintain (as best as possible) the original physical layout of
the text. The default is to 'undo' physical layout (columns,
hyphenation, etc.) and output the text in reading order.
-fixed number
Assume fixed-pitch (or tabular) text, with the specified charac-
ter width (in points). This forces physical layout mode.
-raw Keep the text in content stream order. This is a hack which
often "undoes" column formatting, etc. Use of raw mode is no
longer recommended.
-htmlmeta
Generate a simple HTML file, including the meta information.
This simply wraps the text in <pre> and </pre> and prepends the
meta headers.
-enc encoding-name

關(guān)于怎么在PHP中利用Xpdf讀取PDF的內(nèi)容就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到。

新聞標(biāo)題:怎么在PHP中利用Xpdf讀取PDF的內(nèi)容-創(chuàng)新互聯(lián)
URL網(wǎng)址:http://www.rwnh.cn/article0/csdpio.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站建設(shè)動(dòng)態(tài)網(wǎng)站、網(wǎng)頁(yè)設(shè)計(jì)公司營(yíng)銷型網(wǎng)站建設(shè)、App開發(fā)網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站制作
四会市| 扎鲁特旗| 宜兰县| 攀枝花市| 安乡县| 台中市| 阳东县| 石台县| 鄂尔多斯市| 谢通门县| 新郑市| 教育| 邯郸县| 安宁市| 平乡县| 元朗区| 哈尔滨市| 金寨县| 怀柔区| 济阳县| 娄底市| 康定县| 彭阳县| 肃北| 谢通门县| 同德县| 海盐县| 晴隆县| 乌恰县| 资兴市| 清徐县| 拉孜县| 漯河市| 景德镇市| 富川| 凤冈县| 车致| 岐山县| 衡南县| 中方县| 大连市|