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
lixuda
V2EX  ›  Python

用 Python 把 pdf 文件转到 markdown,有什么好的库或者方案吗?

  •  
  •   lixuda · 2021-03-06 09:55:25 +08:00 · 2772 次点击
    这是一个创建于 1118 天前的主题,其中的信息可能已经有所发展或是发生改变。

    pdf 文件是文本可编辑类型。网上搜索了下,没有找到很好的解决办法,问问大佬,有办法吗?或者转 html,谢谢了。

    10 条回复    2021-03-06 16:35:58 +08:00
    MicroBotter
        1
    MicroBotter  
       2021-03-06 10:28:41 +08:00
    pdf 的文本只有 pdf/a 才是可以编辑的。你是不可能对任意 pdf 转化成合理的文本。
    MicroBotter
        2
    MicroBotter  
       2021-03-06 10:29:34 +08:00
    转换任意 pdf 成文本的难度和写一个识别物体的人工智能难度差不多。
    Latin
        3
    Latin  
       2021-03-06 10:32:05 +08:00
    可以转换,但是样式基本就是纯文本
    Latin
        4
    Latin  
       2021-03-06 10:32:27 +08:00
    PDF to docx ==> html
    Merlini
        5
    Merlini  
       2021-03-06 11:56:49 +08:00 via Android
    pdf 转文本的话,推荐 PyMuPdf 。
    改成 markdown 的话可能你得自己识别里面的字体大小了。
    jdhao
        6
    jdhao  
       2021-03-06 12:05:36 +08:00 via Android
    看看 pandoc 行不行
    SenLief
        7
    SenLief  
       2021-03-06 12:14:54 +08:00
    如果是纯文本有可能转换,要不然效率太低。
    encro
        8
    encro  
       2021-03-06 13:58:51 +08:00
    可以的。
    首先转 html,
    然后语义化,
    转换为 h1,h2,...p 这样的,
    然后换 markdown,很多格式肯定丢掉。

    另外:markdown 一些解释器支持 html 好像。
    inframe
        9
    inframe  
       2021-03-06 16:17:17 +08:00
    那不如先用 office 转换到 word,然后再转换
    omph
        10
    omph  
       2021-03-06 16:35:58 +08:00
    linux 倒是有 Poppler-utils,可以用其中的命令 pdftohtml,转成 html,字体大小倒是可以保留
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1431 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 17:27 · PVG 01:27 · LAX 10:27 · JFK 13:27
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.