We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Exception thrown when calling PdfFileSecurity.SetPrivilege method

This is happening in versions 6.5.0.0 and 6.6.0.0

The exception message is “”." Doesn’t match conditions"

Attached is the pdf that is causing the issue. In the code below, substitute the path to this pdf and any other pdf in the creation of the variable "theLocationMergeFiles"

Code to reproduce is:

string tempFile = “C:\tmpFile.tmp”
string[] theLocationMergeFiles = new [] {“Path to bad pdf”, “Path to any other pdf”};
string theOutFile = “C:\output.tmp”

PdfFileEditor pdfEditor = new PdfFileEditor();

string tempFile = Path.GetTempFileName();
pdfEditor.Concatenate(theLocationMergeFiles, tempFile);


PdfFileSecurity pdfFileSecurity = new PdfFileSecurity(tempFile, theOutFile);

DocumentPrivilege priv = DocumentPrivilege.AllowAll;
priv.AllowModifyContents = false;
priv.AllowModifyAnnotations = false;
priv.AllowCopy = true;
priv.AllowAssembly = false;
priv.AllowFillIn = false;

//Here is where the excpeion is thrown.
pdfFileSecurity.SetPrivilege(priv);

Hi Steve,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for sharing the sample code and template file.

Well, both methods PdfFileEditor.Concatenate and PdfFileSecurity.SetPrivilege should have a PDF file as the (with their complete path) as the arguments. Whereas, you are using “*.tmp” files as arguments which is causing the problem. I tested your share file and perform PDF concatenation with another PDF file and it does not throw any exception.

However, I noticed that while using your provided PDF file in PdfFileEditor.Concatenate method, the resultant concatenated file is not generated. I have registered this issue in our issue tracking system with issue id: PDFNEWNET-33158. We will notify you via this forum thread regarding any update against your issue.

Sorry for the inconvenience,

I mistyped the outFile path in the code sample above.

Try the snippet again with “string theOutFile = “C:\output.pdf””. This should throw the exception when SetPrivilege() is called

Hi Steve,

Thank you for the correction. However, you are using the same ".tmp" extension file for TempFile as well. If I change that to a PDF file as well, it does not give any exception and the only issue is regarding the concatenation which I have already logged in to our issue tracking system. Please confirm it.

Thank You & Best Regards,

I understand, However, the code that uses a .tmp extension for the temp file is something that has been in place for years. Also, the .tmp extension for the temp file is only an issue with certain .pdf files (like the one attached to this post) in versions 6.5.0.0 and 6.6.0.0 of the Aspose.Pdf.dll.

I was hoping that upgrading our Aspose component wouldn’t require us to change code that has been in place for such a long time.


Has any more progress been made on this issue?

Hi Steve,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for being patient.

Your reported issue has been fixed by the development team and the fix will be a part of our next official release of Aspose.Pdf for .NET v6.7 (to be released in early February 2012). You will be notified via this forum thread once the new release is available for download.

Sorry for the inconvenience,

The issues you have found earlier (filed as PDFNEWNET-33158) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.