pdf 转成 word 用 python 实现 - V2EX
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
xxer

pdf 转成 word 用 python 实现

  •  
  •   xxe Apr 30, 2015 9096 views
    This topic created in 4035 days ago, the information mentioned may be changed or developed.

    RT,求教正确姿势。有人用过类似的库吗?实际操作效果如何呢?乱码的情况会不会出现呢?

    13 replies    2015-05-05 18:11:59 +08:00
    pupboss
        1
    pupboss  
       Apr 30, 2015
    我是来搞笑的别打我

    import os

    os.rename('test.pdf', 'test.doc')
    andyhenry
        2
    andyhenry  
       Apr 30, 2015
    pdf是很难转成其他格式的,和用什么语言无关。即使强制转,和单纯用鼠标复制粘贴也差不多,不能保留任何格式。
    nxbtch
        3
    nxbtch  
       Apr 30, 2015
    @pupboss 666
    nowcoder
        4
    nowcoder  
       Apr 30, 2015
    不好转。
    staticor
        5
    staticor  
       Apr 30, 2015
    pypandoc 试试?
    em70
        6
    em70  
       Apr 30, 2015 via Android
    Python不是万能的

    给你个思路,不要纯Python实现,试试去找一个PDF转doc的命令行,python调用命令行来解决。
    xyzasd01
        7
    xyzasd01  
       Apr 30, 2015
    命令行:
    “pdftohtml 文件名”

    然后用word打开html就可以了。

    如果要默认word打开,你把.html改成.doc就可以了。
    xyzasd01
        8
    xyzasd01  
       Apr 30, 2015
    @xyzasd01

    补充一下。pdftohtml的命令是要安装yum install poppler-utils

    然后你pdftohtml,pdftotext之类的一大堆都可以用了。。

    祝好~
    xyzasd01
        9
    xyzasd01  
       Apr 30, 2015
    如果要单纯的去读word。很难,非常难。

    java有tika的库,但是有些读不了,比如猎聘网下载的简历。

    php有phpword,但是只能读取word2007及以上。就是.docx的。

    我的项目遇到的问题:

    读取word,有的是html,有些是真正的word,有些是base64。。。。。。有无数种。。。。需要无数种的方法来读。。html的最简单,base64的要截取一部分,然后unbase64会还原成html。。。。我擦擦
    xxer
        10
    xxer  
    OP
       Apr 30, 2015
    @xyzasd01 也就是说pdf转成word都会存在诸如乱码的问题,不论什么语言,是吗
    jedihy
        11
    jedihy  
       Apr 30, 2015 via iPhone
    @xxer 本质区别是pdf排版类似于用的矢量绘图的方法。word则是文字的编排。这两种方式是不能完美转换的。
    14
        12
    14  
       Apr 30, 2015
    import os
    os.system('libreoffice --headless --convert-to docx my.pdf')
    xyzasd01
        13
    xyzasd01  
       May 5, 2015
    @xxer 不是说一定乱码,只是可能会发生,word太杂了,什么都有。不标准
    About     Help     Advertise     Blog     API     FAQ     Solana     3094 Online   Highest 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 45ms UTC 02:56 PVG 10:56 LAX 19:56 JFK 22:56
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86