【问题标题】:Generate an image from a word file and limit the image to the text in the file从word文件生成图像,并将图像限制为文件中的文本
【发布时间】:2021-07-12 16:36:44
【问题描述】:

我的需要是使用 Python 获取 word 文件中的文本图像。文本长度随每个文件而变化。如何在不包含文档其余部分的空白的情况下检测文本并截取屏幕截图或生成该文本的图像?文本可以跨越多行。

Here is an example of the word file

And this is the result I am looking for

我正在编写一个脚本来读取 word 文件,如上截取屏幕截图,然后将其保存到某个位置。

编辑:已解决。

【问题讨论】:

    标签: python python-3.x automation


    【解决方案1】:

    要提取文本,您可以使用here 列出的众多解决方案中的任何一种

    之后创建一个新的图像,你可以使用 PIL,这里有更多的例子 https://notebooks.ai/santiagobasulto/how-to-generate-images-with-text-using-python-and-pil-bcd5d188 https://code-maven.com/create-images-with-python-pil-pillow

    【讨论】:

    • 我应该补充一点,也可以有方程式,因此将它们作为文本阅读会改变格式。有什么方法可以检测文字并截图。
    猜你喜欢
    • 1970-01-01
    • 2011-12-17
    • 2013-05-03
    • 2010-09-26
    • 2011-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多