推荐学习书目
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
musray
V2EX  ›  Python

请问,python如何识别pdf中的注释?

  •  
  •   musray · Dec 26, 2013 · 6616 views
    This topic created in 4547 days ago, the information mentioned may be changed or developed.
    我有一个pdf文档,其中的一些页面里,包含一些直线或曲线标注的注释。
    我想要做以下事情:
    1. 让python认出这些注释
    2. python把带注释的页提取出来合成一份新的pdf文件。

    关于2:目前用pyPdf找到一些思路,如果能返回我想要的页码,这个问题就容易解决了。

    关于1:这个还没搞清楚。查看了PDFMiner,由于我是初学编程,网上又没有特别对口的实例,所以未果;也有人推荐poppler,这个好像还不是纯python写的,貌似比PDFMiner还要难上手。

    请问大家有什么好办法么?
    6 replies    1970-01-01 08:00:00 +08:00
    crazybubble
        1
    crazybubble  
       Dec 26, 2013
    你可以先用pdfminer试试parse一个sample pdf看看,然后看那些直线和曲线标注的text pdfminer有没有给你特殊处理,我记得是没有的。。。pdfminer好像只能parse出text。而且pdfminer会把fi这个组合parse成一个单独的字符。。
    Shieffan
        2
    Shieffan  
       Dec 26, 2013
    之前搞过,读annotation的话就用poppler-python,最多50行代码。

    写annotation到PDF的话就poppler qt4。

    Linux上的几个PDF reader基本都是基于poppler的,poppler-gtk的文档基本没有,但是qt4的文档比较丰富。
    Shieffan
        3
    Shieffan  
       Dec 26, 2013
    “python把带注释的页提取出来合成一份新的pdf文件”---现成的库你就别想了,除非你自己再写个poppler的python binding。
    musray
        4
    musray  
    OP
       Dec 26, 2013
    @crazybubble 是啊,我在网上搜了搜PDFMiner的用法,好像多是谈论pdf中的文字转txt或者html格式。以后再找时间慢慢熟悉。
    musray
        5
    musray  
    OP
       Dec 26, 2013
    @Shieffan 我只需要读annotation,只好硬着头皮再研究研究poppler。有问题再请教,谢谢。
    musray
        6
    musray  
    OP
       Dec 28, 2013
    @Shieffan 用./configure 安装poppler的时候出现了一个提醒:
    No package 'pygtk-2.0' found
    No package 'atk' found
    No package 'poppler-glib' found

    Consider adjusting the PKG_CONFIG_PATH environment variable if you
    installed software in a non-standard prefix.

    Alternatively, you may set the environment variables PYPOPPLER_CFLAGS
    and PYPOPPLER_LIBS to avoid the need to call pkg-config.
    See the pkg-config man page for more details.

    意思是要手动修改PKG_CONFIG_PATH? 应该如何做呢?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5355 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 43ms · UTC 09:18 · PVG 17:18 · LAX 02:18 · JFK 05:18
    ♥ Do have faith in what you're doing.