小编JBe*_*die的帖子

Python从受密码保护的pdf获取页数

我一直在想办法用python3从密码保护的pdf中获取页面数.到目前为止,我已经尝试过模块pypdf2和pdfminer2.两者都失败了,因为文件没有被解密.

#!/usr/bin/python3
from PyPDF2 import PdfFileReader
pdfFile = PdfFileReader(open("document.pdf", "rb"))
print(pdfFile.numPages)
Run Code Online (Sandbox Code Playgroud)

此代码将产生错误:

PyPDF2.utils.PdfReadError: File has not been decrypted
Run Code Online (Sandbox Code Playgroud)

有没有办法获得没有解密的页数?

python pdf encryption

5
推荐指数
1
解决办法
779
查看次数

标签 统计

encryption ×1

pdf ×1

python ×1