本文整理汇总了Python中pdfminer.pdfparser.PDFDocument.readobj方法的典型用法代码示例。如果您正苦于以下问题:Python PDFDocument.readobj方法的具体用法?Python PDFDocument.readobj怎么用?Python PDFDocument.readobj使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pdfminer.pdfparser.PDFDocument
的用法示例。
在下文中一共展示了PDFDocument.readobj方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PDFExploreCmd
# 需要导入模块: from pdfminer.pdfparser import PDFDocument [as 别名]
# 或者: from pdfminer.pdfparser.PDFDocument import readobj [as 别名]
#.........这里部分代码省略.........
@intarg()
def do_setpos(self, arg):
"Set the current position of the parser to the offset supplied as an argument."
self.parser.setpos(arg)
self.parser.reset()
@intarg(1)
def do_rtok(self, arg):
"Read the next X tokens, X being the supplied argument."
tokens = []
try:
for _ in range(arg):
pos, token = self.parser.nexttoken()
token = str(token)
if len(token) > 20:
token = token[:20] + "[...(%d)]" % (len(token)-20)
tokens.append(token)
except PSEOF:
pass
print(' '.join(tokens))
if len(tokens) != arg:
print("End of file reached")
@intarg(1)
def do_ptok(self, arg):
"Peek the next X tokens, X being the supplied argument. Your current position will not change."
pos = self.parser.lex.lexpos
self.do_rtok(arg)
self.do_setpos(pos)
def do_robj(self, arg):
"Read the next object and sets it as the 'current' object."
objid, genno, obj = self.doc.readobj()
self.current_obj = (objid, genno, obj)
self.do_st('')
@intarg()
def do_sobj(self, arg):
"Select object with ID X. The object has to have been read already."
obj = None
if arg in self.doc._cached_objs:
obj = self.doc._cached_objs[arg]
elif arg in self.doc._parsed_objs:
obj = self.doc._parsed_objs[arg]
else:
print("Object hasn't been read yet.")
strmid, index = self.doc.find_obj_ref(arg)
if index is not None:
print("However, our object id is in a xref")
if strmid:
print("Stream ID: %d" % strmid)
print("Position: %d" % index)
if obj is not None:
self.current_obj = (arg, 0, obj)
self.do_st('')
def do_dbgobj(self, arg):
"Enter in debug mode with current obj as 'obj' in the local scope."
if not self.current_obj:
print("No current obj.")
return
objid, genno, obj = self.current_obj
import pdb; pdb.set_trace()
def do_readall(self, arg):