是否有一种编程方式来确定 PDF 的文本是否可以使用 Python 提取?
Is there a programmatic way to determine whether a PDF's text is extractable using Python?
我只花了 45 分钟试图弄清楚为什么 pyPdf
PageObject.getPage(x).extractText())
没有提取任何东西。我终于给它提供了一个不同的 PDF,它运行良好,让我得出结论,原始 PDF 有某种(非密码)保护。在 Adobe Reader、"page extraction: not allowed."
中确认
我如何(如果有的话)以编程方式确定存在此保护?
这可能会满足您的需求。
x = PageObject.getPage(x).extractText())
if (x == ""): #Or whatever exactly you get when it fails.
raise ValueError("The PDF file can not be imported")
我只花了 45 分钟试图弄清楚为什么 pyPdf
PageObject.getPage(x).extractText())
没有提取任何东西。我终于给它提供了一个不同的 PDF,它运行良好,让我得出结论,原始 PDF 有某种(非密码)保护。在 Adobe Reader、"page extraction: not allowed."
中确认我如何(如果有的话)以编程方式确定存在此保护?
这可能会满足您的需求。
x = PageObject.getPage(x).extractText())
if (x == ""): #Or whatever exactly you get when it fails.
raise ValueError("The PDF file can not be imported")