Decrypt PDF File
Contents
[
Hide
]
Decrypt PDF File using Owner Password
Try online
You can try to unlock document using Aspose.PDF and get the results online at this link: products.aspose.app/pdf/unlock
You can try to unlock document using Aspose.PDF and get the results online at this link: products.aspose.app/pdf/unlock
In order to decrypt a PDF file, you need to create PdfFileSecurity object and then call the DecryptFile method. You also need to pass the owner password to DecryptFile method. The following code snippet shows you how to decrypt PDF file.
public static void DecryptPDFFile() {
PdfFileInfo pdfFileInfo = new PdfFileInfo(_dataDir + "sample_encrypted.pdf");
// Create PdfFileSecurity object
if (pdfFileInfo.isEncrypted()) {
PdfFileSecurity fileSecurity = new PdfFileSecurity();
fileSecurity.bindPdf(_dataDir + "sample_encrypted.pdf");
// Decrypt PDF document
fileSecurity.decryptFile("User_P@ssw0rd");
fileSecurity.save(_dataDir + "sample_decrtypted.pdf");
}
}