Open a password protected PDF File | Python
ฝัง
- เผยแพร่เมื่อ 16 ก.ย. 2024
- This video shows how to decrypt a PDF file using Python Programming. The module that I will be using is PyPDF2.
► Important
Jupyter Notebook File ▸ github.com/the...
PDF file ▸ github.com/the...
► Check out my other profiles
Git Profile ▸ github.com/the...
Linkedin ▸ / thecuriousjuel
Instagram ▸ / thecuriousjuel
Twitter ▸ / thecuriousjuel
► About Me
▸Biswajit Basak
▸B. Tech in Computer Science
▸Batch of 2019
#python #programming #CreatingForIndia
for me it is working fine for normal file but not with password protected
it is working till length of pages but not able to apply further operation
is there any reason for so ?
import PyPDF2
import os
pdf=open(os.path.join(os.getcwd(),"summary¬es\\PyPDF2module\\TheOceanProtected.pdf"),"rb")
pdf_reader=PyPDF2.PdfReader(pdf)
# print(len(PyPDF2.PdfReader(pdf).pages)) --> Throws error because of decrypted file
pdf_reader.decrypt("12345678") #--> password is entered
print(len(pdf_reader.pages))
for i in range(len(pdf_reader.pages)):
for j in range(len(pdf_reader.pages[i].images)):
x=os.path.join("summary¬es\\PyPDF2module",pdf_reader.pages[i].images[j].name)
print(pdf_reader.pages[i].images[j].name)
with open(x,"wb") as file:
file.write(pdf_reader.pages[i].images[j].data)
this is the code i am using working fine for unprotected (no password) pdf but not working for password one
i need help my protected pdf file is a birth date in this format YYYY-MM-DD like this 2000-11-03
can anyone help me, i am a medical doctor and i am not good with this calculations
i tried chat GPT but i can't upload the file, i have python script for it but i can't apply it on the program
i don't know how to make the program read the file and make the calculations on it
Can anyone help me?
Hello, so for the problem that you stated. You need to apply all dates from a starting date to an ending date. Eg. Generate dates starting from 2000-11-03 to 2020-11-03 and try to open the file with each date. Hopefully that helps.