V2EX = way to explore
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
tonghuashuai
V2EX  ›  Python

Python office 文件转 pdf 有没有什么好的方案啊

  •  
  •   tonghuashuai ·
    tonghuashuai · 2015-05-26 11:08:18 +08:00 · 4602 次点击
    这是一个创建于 3251 天前的主题,其中的信息可能已经有所发展或是发生改变。
    环境是:Linux + Python 2.7

    需要将 office 文件转 pdf ,然后 pdf 再用七牛的接口转成图片。
    七牛倒是可以将 office 转 pdf ,http://developer.qiniu.com/docs/v6/api/reference/fop/odconv.html
    但是转的 pdf 不可以再转图片了,现在能想到的是:
    office 文件上传到七牛,转 pdf 下载下来,再传一次 pdf ,然后再转成图片。
    但感觉这样做太纠结了,有没有什么好的方法呢?
    5 条回复    2015-05-26 12:37:28 +08:00
    quix
        1
    quix  
       2015-05-26 11:21:09 +08:00
    libreoffice , python 有不少库封装的
    lerry
        2
    lerry  
       2015-05-26 11:26:59 +08:00
    同libreoffice,seafile用的应该就是这个
    jason52
        3
    jason52  
       2015-05-26 11:37:05 +08:00
    靠楼主你问对人了~俺现在这个回答给你节省不少时间~你先镇定一下!!!

    pdf转图片不用走七牛!!!还网上走一遍多费劲。。用imagemagic~~

    ===
    convert -density 300 -antialias Doc1.pdf doc1.png
    ===

    请叫我雷锋同志(逃
    jason52
        4
    jason52  
       2015-05-26 11:40:17 +08:00
    还有你前半个问题~既然是office,为啥又是linux环境涅~

    liboffice转会有一些问题嘚~

    win下有com接口哒~批处理应该行,不过这部分楼主就是一点也不知道我在说啥了(大雾)~
    geeklian
        5
    geeklian  
       2015-05-26 12:37:28 +08:00
    最佳转换质量的方法就是装个windows,Python + pywin32,win32com
    调word,打开文件,另存pdf。

    linux下搞,有时候字体会变得很细很难看,有时候填充文本的颜色会变,反正就是失真很多...
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   908 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 20:58 · PVG 04:58 · LAX 13:58 · JFK 16:58
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.