PDF Password Removeer

PDF Password Removeer
Windows December 10, 2025 28 Views

import PyPDF2

def remove_pdf_password(input_pdf, output_pdf, password):
   # Open the input PDF
   with open(input_pdf, "rb") as file:
       reader = PyPDF2.PdfReader(file)

       # Check if the PDF is encrypted
       if reader.is_encrypted:
           # Decrypt the PDF using the provided password
           reader.decrypt(password)

           # Create a new PDF writer object
           writer = PyPDF2.PdfWriter()

           # Add each page to the writer
           for page_num in range(len(reader.pages)):
               writer.add_page(reader.pages[page_num])

           # Write the decrypted PDF to a new file
           with open(output_pdf, "wb") as output_file:
               writer.write(output_file)

       print(f"Password removed. New file saved as {output_pdf}")

# Example usage
input_pdf = r"D:\file-Path\Hello.pdf"
output_pdf = r"D:\file-Path\Hello-pdf-unlocked.pdf"
password = "PDF-Password"

remove_pdf_password(input_pdf, output_pdf, password)
 

Leave a Comment

10 Comments

S
Sanghamitra Nandi 7 months ago
Please share latest updated code
🛡 Admin

Hello thanks for the update I will crosscheck and update soon

D
Duggu Duggu 7 months ago
Please check syntax error
T
Tamal Karmakar 7 months ago
FINAL RESULT (WHAT YOU GET)
T
tamalk 7 months ago
very use full content
Y
yuuzvqjgdl 1 months ago
uhplhgwtrilqgyogekvqjzvvqytfgk