一、安装依赖包
pip install --index https://pypi.mirrors.ustc.edu.cn/simple/ python-office
二、pdf转word
2.1 代码实现
import office
office.pdf.pdf2docx(file_path = 'test.pdf')
运行过程如下:
[1/4] Opening document...
[INFO] [2/4] Analyzing document...
[WARNING] 'created' timestamp seems very low; regarding as unix timestamp
[WARNING] 'modified' timestamp seems very low; regarding as unix timestamp
[WARNING] 'created' timestamp seems very low; regarding as unix timestamp
[WARNING] 'modified' timestamp seems very low; regarding as unix timestamp
[INFO] [3/4] Parsing pages...
[INFO] (1/9) Page 1
[INFO] (2/9) Page 2
[INFO] (3/9) Page 3
[INFO] (4/9) Page 4
[INFO] (5/9) Page 5
[INFO] (6/9) Page 6
[INFO] (7/9) Page 7
[INFO] (8/9) Page 8
[INFO] (9/9) Page 9
[INFO] [4/4] Creating pages...
[INFO] (1/9) Page 1
[INFO] (2/9) Page 2
[INFO] (3/9) Page 3
[INFO] (4/9) Page 4
[INFO] (5/9) Page 5
[INFO] (6/9) Page 6
[INFO] (7/9) Page 7
[INFO] (8/9) Page 8
[INFO] (9/9) Page 9
[INFO] Terminated in 1.30s.
Process finished with exit code 0
2.2 pdf内容
2.3 转换后的word
由上可见,效果还不错。