- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我实际上是在使用 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
谁能帮帮我?
最佳答案
正如 Python 文档中所述,模式 'w+b'
打开文件并将其截断为 0 字节,而 'r+b'
打开文件没有截断。
关于python - pyPdf 错误参数无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10706778/
我尝试安装这个包... $ pip search pyPdf PyPDFLite - Simple PDF Writer. pypdfocr
使用它时出现意外错误。第一部分来自我在网上找到的脚本,我试图用它来提取 PDF 大纲中标识的特定部分。一切正常,除了在 output.write(outputfile1)它说: PdfReadErro
Here我找到了用于拆分 pdf 页面的代码。 #!/usr/bin/env python import copy, sys from pyPdf import PdfFileWriter, PdfF
使用 pypdf python 模块如何读取以下 pdf 文件 http://www.envis-icpe.com/pointcounterpointbook/Hindi_Book.pdf # -*-
我是Python新手。我尝试打开pdf文件并将其内容写入新的文本文件。文本文件名称由 pdf 名称生成。到目前为止我已经尝试过,但它没有达到我的预期。我怎样才能实现它 import glob,
我实际上是在使用 pyPdf 打开、读取和写入 PDF 文件的内容。 为此,我使用了这些代码行: from pyPdf import PdfFileWriter, PdfFileReader pdf
按照这个例子,我可以将所有元素列成一个pdf文件 import pyPdf pdf = pyPdf.PdfFileReader(open("pdffile.pdf")) list(pdf.pages)
如果我有 1000 多个 pdf 文件需要合并为一个 pdf, from PyPDF2 import PdfReader, PdfWriter writer = PdfWriter() for i i
我有一个 PDF 文件(A4,纵向布局),我想将其中的每一页分成一半高度。输出文件也应该是A4和纵向布局,但每页的下半部分需要是空白的。 我看到了https://stackoverflow.com/a
我有一个 PDF 文件(A4,纵向布局),我想将其中的每一页分成一半高度。输出文件也应该是A4和纵向布局,但每页的下半部分需要是空白的。 我看到了https://stackoverflow.com/a
我正在运行以下代码来创建一个新的 PDF 文件,其中包含源 PDF 的除第一页之外的所有页面: import os from pyPdf import PdfFileReader, PdfFileWr
这个问题在这里已经有了答案: How can I rotate a page with PyPDF2? (2 个答案) 关闭 12 个月前。 我们有一个简单的脚本来读取传入的 PDF 文件。如果是横
目前,如果我使用 pyPdf 和 extractText() 创建一个 pdf 页面的页面对象,会发生什么行被连接在一起。例如,如果页面的第 1 行说“hello”而第 2 行说“world”,则从
目前我正在研究将 PDF 与 pyPdf 合并,但有时输入的顺序不正确,所以我正在研究抓取每一页的页码以确定它应该进入的顺序(例如,如果有人将一本书分成 20 份 10 页的 PDF,而我想将它们重新
我在 Windows 平台上使用 Python 2.4 和 PyPdf 1.13。我正在尝试使用以下代码将列表中的 PDF 文件合并为一个文件: import os from pyPdf import
我想将几个 PDF 文件合并为一个 PDF 文档。事实证明,输入文件并不完全符合标准。 EOF 标记后跟一些附加信息: >> startxref 1994481 %%EOF %%PPIRoute: 4
我有以下代码: import os from pyPdf import PdfFileReader, PdfFileWriter path = "C:/Real Python/Course mater
我正在尝试将 PDF 的每一页提取为字符串: import pyPdf pages = [] pdf = pyPdf.PdfFileReader(file('g-reg-101.pdf', 'rb')
我正在尝试使用 pyPdf 从多页 PDF 中提取和打印页面。问题是,文本不是从某些页面中提取的。我在这里放了一个示例文件: http://www.4shared.com/document/kmJF6
我正在尝试使用 pyPDF 编写几个 python 脚本,将 PDF 页面拆分为六个单独的页面,正确排序它们(通常正面和背面打印,因此每个其他页面都需要以不同方式排序),并删除结果输出文档末尾的空白页
我是一名优秀的程序员,十分优秀!