我正在使用pyPdf打开、阅读和写入PDF文件内容。
为此,我使用以下代码行:
from pyPdf import PdfFileWriter, PdfFileReader
pdf = PdfFileReader(file("/myPdfFile.pdf", "w+b"))
content = pdf.getPage(1).extractText()
print content
但是它返回了一个错误,我不太明白为什么。
File "/usr/local/lib/python2.6/dist-packages/pyPdf/pdf.py", line 374, in __init__
self.read(stream)
File "/usr/local/lib/python2.6/dist-packages/pyPdf/pdf.py", line 702, in read
stream.seek(-1, 2)
IOError: [Errno 22] Invalid argument
Anyone can help me?