在pdfminer中输入坐标并获得结果

时间:2016-02-23 09:35:06

标签: python pdfminer

我正在尝试通过输入坐标来提取pdf矿工中的文本,我搜索了互联网,但找不到任何与之相关的文档或代码。到目前为止,我找到了一个提取文本并输出其共同的代码。坐标。

LTTextBoxHorizontal
(317.564, 91.32756, 580.93228, 116.24235999999999)
SHOULD ANY OF THE ABOVE DESCRIBED POLICIES BE CANCELLED BEFORE
THE    EXPIRATION   DATE    THEREOF,    NOTICE   WILL   BE   DELIVERED   IN
ACCORDANCE   WITH   THE   POLICY   PROVISIONS.

这是我获得的输出坐标和文本之一。我也尝试过 pdfquery ,但是我遇到了很多错误。

File "C:\Python27\lib\site-packages\pyquery-1.2.11-py2.7.egg\pyquery\pyquery.py", line 268, in __call__
    result = self._copy(*args, parent=self, **kwargs)
  File "C:\Python27\lib\site-packages\pyquery-1.2.11-py2.7.egg\pyquery\pyquery.py", line 253, in _copy
    return self.__class__(*args, **kwargs)
  File "C:\Python27\lib\site-packages\pyquery-1.2.11-py2.7.egg\pyquery\pyquery.py", line 239, in __init__
    xpath = self._css_to_xpath(selector)
  File "C:\Python27\lib\site-packages\pyquery-1.2.11-py2.7.egg\pyquery\pyquery.py", line 249, in _css_to_xpath
    return self._translator.css_to_xpath(selector, prefix)
  File "build\bdist.win32\egg\cssselect\xpath.py", line 192, in css_to_xpath
  File "build\bdist.win32\egg\cssselect\parser.py", line 355, in parse
  File "build\bdist.win32\egg\cssselect\parser.py", line 370, in parse_selector_group
  File "build\bdist.win32\egg\cssselect\parser.py", line 378, in parse_selector
  File "build\bdist.win32\egg\cssselect\parser.py", line 437, in parse_simple_selector
  File "build\bdist.win32\egg\cssselect\parser.py", line 535, in parse_attrib
cssselect.parser.SelectorSyntaxError: Expected string or ident, got <NUMBER '1' at 14> 

有人可以帮我吗?

1 个答案:

答案 0 :(得分:4)

当你没有逃脱 pageid 值时会发生这种情况。

<强>尝试:

LTPage[pageid=\'1\']