The following worked for me:
from PyPDF2 import PdfFileReader pdf = PdfFileReader(open('path/to/file.pdf','rb')) pdf.decrypt(password) print pdf.getNumPages()
I would recommend removing read protection using a command line tool such as qpdf (itβs easy to install, for example, on a Ubuntu, use apt-get install qpdf if you donβt already have one):
qpdf --password=PASSWORD --decrypt SECURED.pdf UNSECURED.pdf Then open the unlocked file with pdfminer and make your own material.
source share