Skip to content

Instantly share code, notes, and snippets.

@aspose-com-kb
Last active January 14, 2023 10:37
How to Decrypt PDF File using Python. For more details: https://kb.aspose.com/pdf/python/how-to-decrypt-pdf-file-using-python/
import aspose.pdf as pdf
#Set the source directory path
filePath = "C://Words//"
# Load the license in your application to decrypt the PDF
decryptPdfLicense = pdf.License()
decryptPdfLicense.set_license(filePath + "Conholdate.Total.Product.Family.lic")
# Load the source PDF document with password from the disk
decryptPdfDoc = pdf.Document(filePath + "Output.pdf","owner")
# Decrypt the PDF
decryptPdfDoc.decrypt()
# Save the decrypted PDF file on the disk
decryptPdfDoc.save(filePath + "GeneratedPdf.pdf")
print("PDF decryption done")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment