NullReference when removing a signature from a PDF Document

Hello all,


When I try to remove a signature from certain pdf documents I’ get a nullreference exception without any further details. The code is

using AspKit = Aspose.Pdf.Facades;

using (AspKit.PdfFileSignature pdfSig = new AspKit.PdfFileSignature())
{
pdfSig.BindPdf(PdfPath);
int anzahlSignaturen = pdfSig.GetSignNames().Count;
foreach (string signName in pdfSig.GetSignNames())
{
pdfSig.RemoveSignature(signName, true);
}
pdfSig.Save(PdfPath);
}

It works with most documents but with some pdf documents it does not work. May be its because they are PDF/A documents.

I am using Apsose.Pdf Kit Version 8.5

I enclosed the PDF document that results to an error.

Thank you for taking your time looking into this,
Kind regards,
Peter

Hi Peter,

Thanks for contacting support.

It appears that you are using legacy Aspose.Pdf.Kit for .NET for signature removal. However during my testing with latest release of Aspose.Pdf for .NET 11.4.0 where I have used following code snippet and I am unable to notice any issue. Can you please try using the latest release and share your findings.

Please note that starting July-2011, Aspose.Pdf.Kit for .NET was merged into Aspose.Pdf for .NET and all its classes and enumerations were merged under Aspose.Pdf.Facades namespace of Merged Aspose.Pdf API. For more information, please visit

  • [Migration from Aspose.Pdf.Kit](http://www.aspose.com/docs/display/pdfnet/Migration+from+Aspose.Pdf.Kit)
  • [Changes in Operator class names](http://www.aspose.com/docs/display/pdfnet/Changes+in+Operator+class+names)

[C#]

using (Aspose.Pdf.Facades.PdfFileSignature
pdfSig = new Aspose.Pdf.Facades.PdfFileSignature())<o:p></o:p>

{

pdfSig.BindPdf("c:/pdftest/TestDokumentSigned.pdf");

int anzahlSignaturen = pdfSig.GetSignNames().Count;

foreach (string signName in pdfSig.GetSignNames())

{

pdfSig.RemoveSignature(signName, true);

}

pdfSig.Save("c:/pdftest/TestDokumentSigned_Removed.pdf");

}