尝试使用 camelot-py 绘制 pdf 表格,但没有出现表格

问题描述 投票:0回答:2

我正在尝试绘制表格以进行调试并查找表格坐标,但是该图从未出现在屏幕上。 Camelot 内置了使用 matplotlib 库绘制表格的函数。我已经为 camelot 下载了所有依赖项,但我似乎无法弄清楚如何让这个数字出现。


tables = camelot.read_pdf('example.pdf', flavor = 'lattice')

print(tables[0].parsing_report)

plt = camelot.plot(tables[0], kind='grid')
plt.show()

python matplotlib python-camelot
2个回答
2
投票

我只需要在 .show() 函数之后添加 Tkinter .mainloop() 函数,以保持图形在我关闭它之前。没有它,图形会立即关闭,以便代码可以一直运行。


0
投票

从已安装的 cli.py 复制 我这样解决了:

#!/usr/bin/python3
import camelot

import matplotlib.pyplot as plt # this to add


tables = camelot.read_pdf('example.pdf', flavor = 'lattice')

print(tables[0].parsing_report)

# was
# plt = camelot.plot(tables[0], kind='grid')

# new
camelot.plot(tables[0], kind='grid')

plt.show()
© www.soinside.com 2019 - 2024. All rights reserved.