赞
踩
pip install PyMuPDF
import fitz # this is PyMuPDF
# doc1 = "IOT.pdf"
with open(r"C:\Users\84977\Desktop\test2.pdf", 'r+') as doc1:
doc = fitz.Document(doc1)
# the document should be password protected
print(doc.isEncrypted)
pip install PyPDF3
import PyPDF3
pdffile= open('IOT.pdf', 'rb')
pdfreader= PyPDF3.PdfFileReader(pdffile)
try:
# print decryption outcome as 1 if successful and 0 otherwise
pdfreader.decrypt('password')
except NotImplementedError as errMsg:
print(pdfreader, 'can not be decrypted on error message', errMsg)
pdffile.close()
pip install PyPDF2
# -*- coding: utf-8 -*-
import PyPDF2
# 打开PDF文件
with open(r'C:\Users\84977\Desktop\加密的pdf.pdf', 'rb') as pdf_file:
# 创建一个PdfFileReader对象
pdf_reader = PyPDF2.PdfFileReader(pdf_file)
# 确认PDF是否受密码保护
if pdf_reader.isEncrypted:
print("PDF文件受密码保护")
else:
print("PDF文件没有密码保护")
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。