(I have uploaded and linked to a sample file that is causing the crash towards the end of this post)
I am trying to encrypt a PDF file that has attachments inside it. One of the attachments is a PDF file that is itself encrypted.
My VB.Net code crashes (saying invalid password).
Public Sub EncryptPDF(fileName As String, userPassword As String, ownerPassword As String)
Dim document = New Aspose.Pdf.Document(fileName)
document.Encrypt(userPassword, ownerPassword, 0, Aspose.Pdf.CryptoAlgorithm.AESx256)
The code will work if the file that I am putting inside my new pdf was not previously encrypted.
I thought my code may have an error so I also tried encrypting the same file at the Aspose free lock website and that fails too:
Here is a sample PDF file. I actually created this file with Aspose PDF. If I try and encrypt this with the code above, the code fails.
email.pdf (148.9 KB)
You will see that this PDF has another encrypted PDF inside it.
I don’t want to modify the original PDF in anyway… The new PDF is meant to simply serve as a container for it but then I want to encrypt the container pdf too.
Do I need to do anything extra to make this work.