Aspose PDF SetPrivilege

I am using Aspose to remove file security for PDF documents. The code works perfectly for PDF docs that are version 1.5 or earlier. When I run this code against a PDF version 1.6, it corrupts the document.



I have attached a screenshot of the code and a sample PDF file.



In the screenshot, the line highlighted in YELLOW is the key line. When I comment out this line, the code does not corrupt the PDF doc.

Hi Bryan,

Thanks for contacting support.

I have tested the scenario using Aspose.Pdf for .NET 12.0.0 and I am unable to notice any issue. Can you please try using latest release and in case you still face the same issue, please share the sample project.

We are sorry for this inconvenience.

[C#]

// Instantiate a Document object by calling its empty constructor
using (Document doc = new Document(@"C:\pdftest\0028738\orig.pdf"))
{
    using (PdfFileSecurity security = new PdfFileSecurity(doc))
    {
        security.SetPrivilege(DocumentPrivilege.AllowAll);
        security.Save(@"C:\pdftest\0028738\orig_Security.pdf");
    }
}

This small portion of code is actually part of a large software package that uses Aspose 11. Upgrading to Aspose 12 would be a very time consuming process.

Can you confirm that it is my only option?

Hi Bryan,


Thanks for sharing the details.

In order to replicate the issue, we need the sample project and I am afraid unless we reproduce the issue in our environment, we may not be able to share the possible resolution regarding this problem. Or you may try using the latest release and share your findings.

We have a large enterprise class piece of software that contains the Aspose DLLs. I wrote one small module to set the privs on PDF docs. The code that I use in my module is attached as a screenshot in my original request. It is virtually the same code that you sent in your original reply.

If you run the given document through that code using Aspose 11.0, you will see the exact issue I am having.

While I understand that maybe this issue was resolved in 12.0, it is going to be a big deal for us to upgrade so I want to explore all options first.

Hi Bryan,

Thanks for sharing the details.

Aspose.Pdf for .NET 11.0.0 is quite old release. However I have tested the scenario using Aspose.Pdf for .NET 11.3.0 which is the oldest version I have and I am unable to notice any problem when using following code snippet with ecopy+Version1.6±+Copy.pdf file.

[C#]

// Instantiate a Document object by calling its empty constructor
using (Document doc = new Document(@"C:\pdftest\ecopy+Version1.6+-+Copy.pdf"))
{
    using (PdfFileSecurity security = new PdfFileSecurity(doc))
    {
        security.SetPrivilege(DocumentPrivilege.AllowAll);
        security.Save(@"C:\pdftest\ecopy+Version1.6+-+Copy_Security.pdf");
    }
}

Just to confirm…

Using 11.0.3, you were able to run the code and remove the security from the document. Additionally, you were able to view the document after removing security. Is this correct?

Can you attach the new document so I can get a copy?

Hi Bryan,


Thanks for your patience.

I have again tested the scenario and have managed to reproduce same problem that file is being corrupted when trying to update security information for PDF document. For the sake of correction, I have logged it as PDFNET-41576 in our issue tracking system. We will further look into the details of this problem and will keep you posted on the status of correction. Please be patient and spare us little time. We are sorry for this inconvenience.

Bryan has moved on to another company, but we here still need to know so I’m commenting to keep the thread alive.

@eversdan,

Thanks for contacting support.

The earlier reported issue is still pending for review and is not yet resolved. However as soon as we have some definite updates regarding its resolution, we will update you within this forum thread. Please be patient and spare us little time.

The issues you have found earlier (filed as PDFNET-41576) have been fixed in Aspose.PDF for .NET 19.3.