Skip to content

tjwei/translatePDF

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 

Repository files navigation

可將一些簡體的文字版 PDF 轉成繁體。
使用 Python 2.7
需安裝 pdfrw, opencc, pdftk, chardet, fontTools, droid-sans-fallback.ttf
在 ubuntu 上,除了 fontTools 外,其他可用 apt-get 安裝。
python 的 module 大多可用 pip 安裝。
fontTools 暫時無法,請到 http://sourceforge.net/projects/fonttools/ 下載安裝。
(解開後 `sudo python2 setup.py install` 即可)

執行方式為 
```bash
python2 tpdfrw.py xxx.pdf
```

usage: tpdfrw.py [-h] [--opencc-config OPENCC_CONFIG]
                 [--default-ttf DEFAULT_TTF] [--output-prefix OUTPUT_PREFIX]
                 input [output]

Translate a PDF file from/to different variations of Chinese language

positional arguments:
  input                 input pdf file
  output                output pdf file name (default: None)

optional arguments:
  -h, --help            show this help message and exit
  --opencc-config OPENCC_CONFIG
                        opencc config (default: zhs2zhtw_vp.ini)
  --default-ttf DEFAULT_TTF
                        default TTF/OTF font file name (default:
                        /usr/share/fonts/truetype/droid/DroidSansFallback.ttf)
  --output-prefix OUTPUT_PREFIX
                        default output prefix. Ignored when output file name
                        is given (default: [translated])

因為解碼支援不完整,也可以試試看先
```bash
qpdf --qdf --object-streams=disable xxx.pdf xxx-decoded.pdf
```
然後再
```bash
python2 tpdfrw.py xxx-decoded.pdf
```

PyOpenCC.py 是從 opencc source code 裡面拿來的 ctypes wrapper。

相關資訊: 
影片展示效果: http://www.youtube.com/watch?v=pNzXKE10KWk
Blog 文章: http://weijr-note.blogspot.tw/2012/07/pdf.html
Blog 文章: http://weijr-note.blogspot.tw/2012/07/pdf-github-todo.html

Code License: Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0

About

Convert Simplized Chinese PDF to Traditional Chinese PDF

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages