我正在对从url下载的文件执行数据验证。其中一个验证检查涉及检查PDF的页数。使用PyPDF2包和PdfFileReader模块,直到我遇到一个具有权限密码但没有打开密码的256位AES加密的PDF。我无法访问任何密码,因为这些文件来自制造商网站,所以我的结论是,目前我只需检查PDF是否加密,如果是的话,暂时跳过它,但不管我是否试图检索页面计数或检查PDF是否加密,我都会得到以下错误:
DependencyError: PyCryptodome is required for AES algorithm
此错误发生在第6行if语句中。
尽管已经安装了pycryptodome并导入了AES模块,
import os
import glob
import comtypes.client
from PyPDF2 import PdfFileMerger
def docxs_to_pdf():
"""Converts all word files in pdfs and append them to pdfslist"""
word = comtypes.client.CreateObject('Word.Application')
pdfslist = PdfFileMerger()
我已经通过wsl在windows上安装了miniconda和jupyter。虽然服务器启动了,但我无法在浏览器中打开它。因此,我无法访问启动的jupyter笔记本。 附件中的屏幕截图相同。Successful server started Unable to open in browser 我尝试使用"localhost“或"127.0.0.1”从运行时.html文件打开笔记本。我还尝试使用命令"jupyter- notebook“运行notebook,我在bashrc中定义了它的别名。请帮帮忙。
我需要删除最后一页的pdf文件。我有多个pdf文件在同一个目录中。到目前为止,我有下一个代码:
from PyPDF2 import PdfFileWriter, PdfFileReader
import os
def changefile (file):
infile = PdfFileReader(file, "rb")
output = PdfFileWriter()
numpages = infile.getNumPages()
for i in range (numpages -1):
p = infile.get
我有一个类似下面的用例: files = [open("foo1.pdf", "rb"), open("foo2.pdf", "rb"), open("foo3.pdf", "rb")]
# ... extract portions from the opened files using PyPDF2 and assemble a new PDF file
map(close, files) 为什么我要这么做呢?因为在使用PyPDF2将多个输入PDF文件合并到另一个文件中时,如果关闭每个输入PDF
我编写了一个从PDF文档中提取文本的程序。但一份PDF文件给了我空的短信。我可以在Acrobat中打开PDF文件,它可以正常工作。我的代码可以很好地处理其他PDF文件,所以我想知道是什么导致了这个问题。我用了PyPDF2和PyPDF2,但结果是一样的。所以这个文件一定有问题:
我的密码
from PyPDF2 import PdfReader
reader = PdfReader("example.pdf")
for page in reader.pages:
text = page.extract_text()
print(text)
我做的不仅仅是
我对Python/编程非常陌生,正在尝试自动化一项非常耗时的办公任务。 我有多个包含PDF的文件夹。对于每个文件夹,我需要将PDF合并为一个PDF,并将其保存在内容为其总和的文件夹中。我已经将一个文件夹的内容组合在一起,并使用以下命令成功地保存到我的桌面: import PyPDF2
import os
Path = '/Users/jlaw/Desktop/Testing/FolderName/'
filelist = os.listdir(Path)
pdfMerger = PyPDF2.PdfFileMerger(strict=False)
for file in fi
也许这根本不起作用,因为它是一台Mac,但也许有一种方法可以在Mac上打开jupyter笔记本?我尝试了以下命令
jupyter notebook Manager.ipynb
我得到了一个错误
Error executing Jupyter command 'notebook': [Errno 2] No such file or directory. Same with out 'notebook':
jupyter Manager.ipynb
Error executing Jupyter command 'Manager.ipynb'
我有很多pdf页面,我想把它们合并成一个文件。
我的脚本如下:
from PyPDF2 import PdfFileMerger,PdfFileReader
filename_list=[]
merger = PdfFileMerger()
for i in range (0,66):
filename='page'+str(i)+'.pdf'
if not filename in filename_list:
filename_list.append(filename)
for filename in filename_list