Forum Discussion
How to delete password from pdf on Windows as it is password protected?
For a completely code-based, free method that many might not know about, Free Spire.PDF for Python is a great library. It's a "completely free" way to delete password from PDF by writing just a few lines of Python code.
How to Use Free Spire.PDF:
1. Install the Library: Open your command prompt or terminal and run pip install Spire.PDF.Free.
2. Write the Script: Create a new Python file (e.g., unlock.py) and write this script, replacing the file paths and password with your own:
python
from spire.pdf import *
# Create a PdfDocument object
doc = PdfDocument()
# Load the password-protected PDF file with its password
doc.LoadFromFile("C:/input/your_protected_file.pdf", "your_password")
# Set the password to empty strings to remove protection
doc.Security.Encrypt(str(), str(), PdfPermissionsFlags.Default, PdfEncryptionKeySize.Key128Bit, "permissionpassword")
# Save the unsecured PDF file
doc.SaveToFile("C:/output/unlocked_file.pdf", FileFormat.PDF)
doc.Close()
3. Run the Script: Execute the script, and it will create a new, password-free PDF in the output location you specified.
If your PDF is 10 pages or less, this is a very effective, free, and offline method to delete password from PDF file. You just need to know the password and be ready to write or copy a few lines of Python code.