7.25. xpdf - 中文 PDF 的顯示

xpdf 是用來瀏覽 Portable Document Format (PDF) 檔案的好工具。 (通常也會稱這些檔案為 'Acrobat' 檔,因為 Adobe 的 PDF 軟體)

安裝 graphics/xpdf

Note: 在 2.x 安裝完後,只要在 ~/.Xdefaults 中設定中文字型,就可以很正常的看非內嵌中文的檔案。

xpdf.chineseCNSFont: -*-*-medium-r-normal-*-%s-*-*-*-*-*-big5-0
xpdf.chineseGBFont: -*-*-medium-r-normal-*-%s-*-*-*-*-*-gb2312.1980-0

現在 xpdf 已經將 xpdf 中的 CMap 與主程式分開了, 如果要看到中文還必須安裝 xpdf 的 CMap 檔。 當您看到這樣子的錯誤訊息:

Error: Couldn't find cidToUnicode file for the 'Adobe-CNS1' collection
Error: Unknown character collection 'Adobe-CNS1'

Error: Couldn't find 'ETen-B5-H' CMap file for 'Adobe-CNS1' collection
Error: Unknown CMap 'ETen-B5-H' for character collection 'Adobe-CNS1'

則表示沒安裝 xpdf CMap,所以要安裝 chinese/xpdf 並設定好字型。

如果裝好還看到以下的訊息:

Error: Couldn't find 'ETenms-B5-H' CMap file for 'Adobe-CNS1' collection
Error: Unknown CMap 'ETenms-B5-H' for character collection 'Adobe-CNS1'

這是因為 ETenms-B5-H 已經不在 Adobe 的現存標準內, 您可以手動把 /usr/local/share/ghostscript/Resource/CMap/ 底下的 ETen-B5-H 拷貝成 ETenms-B5-H

如果遇到 Error: Couldn't find a font to substitute for 'ShanHeiSun-Light' ('Adobe-CNS1' character collection) ,那麼就要改一下 xpdfrc:

psNamedFont16 ShanHeiSun-Light H ShanHeiSun-Light-B5-H Big5
psFont16 ShanHeiSun-Light H ShanHeiSun-Light-B5-H Big5

xpdf 中也包含一個 PDF 轉純文字檔的程式, 可以用 pdftotext -enc Big5ascii file.pdf 轉出文字檔 file.txt,如果只用 -euc Big5 英文會變成全形字。

xpdf-2.03 已加入 pdf bookmarks 的顯示功能,只是中文還不行。

Figure 7-13. xpdf snapshot

WWW: xpdf project