Free Support Forum -

NullReferenceException when SetPrivilege is used on a concatenated PDF

I’m using PDF Kit Whenever I use PdfFileSecurity.SetPrivilege on a PDF that has been created by PdfFileEditor.Concatenate, a NullReferenceException is internally thrown, caught, and ignored. This makes for a bad experience if you’re attached with a debugger and the debugger is set to break whenever an exception is thrown.

The Aspose code would perform better if the “exceptional” condition were checked for explicitly. You shouldn’t use throw+catch+ignore when you could internally just use a simple bool check instead. Also, it seems buggy that this exception only occurs when calling SetPrivilege on a PDF created by PdfFileEditor.Concatenate. When I use SetPrivilege on PDFs created by other code (e.g., PrimoPDF or Aspose.Words.Document.Save), then this NullReferenceException doesn’t occur.

I’ve attached a zip file of a C# project that demonstrates this issue. A sample call stack from it is shown below.

Aspose.Pdf.Kit.dll!xeb116a323308e2f7.xe08d3ad86a4699d9.iterateFields(xeb116a323308e2f7.x60d978557e549fe1 fieldlist = null, xeb116a323308e2f7.x081daeabc28689ee fieldDict = null, string title = null) + 0x8e bytes

Aspose.Pdf.Kit.dll!xeb116a323308e2f7.xe08d3ad86a4699d9.readAcroForm(xeb116a323308e2f7.x0b25947bdf0fba40 root = {xeb116a323308e2f7.x0b25947bdf0fba40}) + 0xc6 bytes

Aspose.Pdf.Kit.dll!xeb116a323308e2f7.x7759a935a2782a02.AcroForm.get() + 0x104 bytes

Aspose.Pdf.Kit.dll!Aspose.Pdf.Kit.PdfFileEditor.xccb2935df28bfbf9(x833cb12bef83f1f9.x2c8c6741422a1298 x3664041d21d73fdc = {x833cb12bef83f1f9.x2c8c6741422a1298}, xeb116a323308e2f7.x10bc81502b9cfac5 xbdfb620b7167944b = {xeb116a323308e2f7.x10bc81502b9cfac5}, xeb116a323308e2f7.x7759a935a2782a02 xe134235b3526fa75 = {xeb116a323308e2f7.x7759a935a2782a02}, int x9542370f777d8414 = 1, int x7ad47f71c8fff7a8 = 4) + 0x1ba bytes

Aspose.Pdf.Kit.dll!Aspose.Pdf.Kit.PdfFileSecurity.x2c82a20d46df9cb6(string x682935b2be2ef7d8 = “owner”, string xa9cf4de0fffcf1a9 = “”, string xd005ab558c255f3c = “owner”, Aspose.Pdf.Kit.DocumentPrivilege x8390a7e61fd0335c = {Aspose.Pdf.Kit.DocumentPrivilege}, bool x7f867ab99fcc7ef0 = true) + 0x437 bytes

Aspose.Pdf.Kit.dll!Aspose.Pdf.Kit.PdfFileSecurity.SetPrivilege(string userPassword = “”, string ownerPassword = “owner”, Aspose.Pdf.Kit.DocumentPrivilege privilege = {Aspose.Pdf.Kit.DocumentPrivilege}) + 0x67 bytes

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

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

I'm now using PDF Kit, but it does not fix this problem. If you update the Aspose.Pdf.Kit reference in the attached C# project to use version, it will still internally generate and ignore a NullReferenceException.

If you set the debugger to break whenever a CLR exception is thrown, you'll see it stop at the NullReferenceException. If you don't break when the exception is thrown, you'll see the following message in the debugger's Output window:

A first chance exception of type 'System.NullReferenceException' occurred in Aspose.Pdf.Kit.dll

Note: Aspose issue 10117 does fix the ArgumentOutOfRangeException issue I reported in another thread, but it doesn't fix the NullReferenceException issue reported in this thread.

Hi Bill,

This issue is logged as PDFKITNET-11235 in our issue tracking system. Our team will be looking into the matter and you’ll be updated via this forum as the issue is resolved.

We’re sorry for the inconvenience.

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

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