Free Support Forum - aspose.com

I get an Object reference not set when trying to Signa PDF with UseLTV = true

I use the following code and when we set UseLtv = true, we got an Obj ref not set error on the save method.

Here is the code:

using (Document document = new Document(“c:\temp\a.pdf”))
{
using (PdfFileSignature signature = new PdfFileSignature(document))
{
X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
store.Open(OpenFlags.ReadOnly);
X509Certificate2Collection certificates = store.Certificates.Find(X509FindType.FindByThumbprint, “58944ba2c6fdb351fcf2d293edf1e3f7a4def250”, false);

                System.Drawing.Rectangle rect = new System.Drawing.Rectangle(100, 100, 200, 100);

                
                
                ExternalSignature extSig = new ExternalSignature(certificates[0]);
                extSig.UseLtv = true;
                signature.Sign(1, "Signature Reason", "Contact", "Location", true, rect, extSig);

                signature.Save("c:\\temp\\NonWorking.pdf");
            }
        }

@sigma

We have tested the scenario in our environment while using one of our sample files and Aspose.PDF for .NET 20.12. We were able to replicate the exception that you have mentioned and have logged it as PDFNET-49258 in our issue tracking system. We will look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.

We are sorry for the inconvenience.