PDFSecurityException

PDFSecurityException

Forum member · Aug 13, 2009
I am actually using DynamicPDF Merger for .NET v2.x (Visual Studio 2005) Here is my code: protected void Page_Load(object sender, EventArgs e) { // Create a merge document and set it's properties MergeDocument document = MergeDocument.Merge( MapPath( "PDFs/s000015.pdf" ), MapPath( "PDFs/s000171.pdf")); // Append additional PDF document.Append( MapPath( "PDFs/s000177.pdf" ) ); // Outputs the merged document to the current web page document.DrawToWeb( "MergePDFs.pdf" ); } When I run this code, the first line of this function (the MergeDocument.Merge line), gives the following run-time error: PdfSecurityException Document cannot be decrypted. Invalid owner password What am I doing wrong? Thank You! Becky McDermott

Re: PDFSecurityException

Support · Aug 13, 2009
Hello Becky, It looks like you are merging a PDF which is encrypted with a owner password. In order to merge encrypted PDF documents you have to provide the password for the document while merging. In order to merge encrypted PDF documents, you have to use the PdfDocument object which takes password as the parameter in one of its overloaded constructor, and pass this PdfDocument object to the overloaded MergeDocument's constructor. This will resolve your problem. Thanks, ceTe Software Support Team

Re: PDFSecurityException

Forum member · Jan 15, 2020
Hi I am able to open the PDF without any password.But when I tried to create stream of the same PDF using PDFDocument Obejct ,I am getting this Error "Document can not be decrypted. Invalid owner password."

Re: PDFSecurityException

Support · Jan 15, 2020
Hi, Encrypted PDFs can have an owner and user password. If the user password is blank (""), it is possible to open an encrypted PDF without specifying a password in a PDF viewer. If you want to edit or merge an encrypted PDF though, you will need to specify the owner password. In order to work with an encrypted PDF in our product, you need to specify the owner password. Thanks, ceTe Software Support

Re: PDFSecurityException

Forum member · Jul 20, 2020
Hello, I have an encrypted document that includes an xfa form which can be edited (the form, I mean) without a password. I can edit and save with Acrobat Reader, (and I can read with other libraries as well, though the digital signature breaks if I save). But when trying to open it with DynamicPDF, I get the execption 'Document can not be decrypted. Invalid owner password.'. Is there any setting that would allow me to open this document? Thank you.

Re: PDFSecurityException

Support · Jul 20, 2020
Hello, There are two types of passwords that one can set to a PDF: 1. User Password – If this is set you will need to provide the password for viewing the PDF. 2. Owner Password – If this is set you will need to provide the password for editing and/or merging the PDF. In the case of your PDF it is possible that only owner password was set and not the user password. Hence you are able to open and view the PDF but not able to modify or merge it without the owner password. You will need to load the password protected (secured) PDF using PdfDocument class constructor which takes a file path/byte array and owner password as arguments. Then append or merge it with the MergeDocument object. Below is a code sample for it. Please note that it is not possible to merge an owner password protected PDFs without specifying the correct owner password. PdfDocument pdfDoc = new PdfDocument(@"Secured PDF file path", "correct owner password"); MergeDocument document = new MergeDocument( ); document.Append(pdfDoc); document.Draw(@"C:\temp\MyOutput.pdf"); Thanks, ceTe Software Support Team