We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Issue in Signing PDF with x509certificate2 Stored In USB Token'

I am trying to add x509 certificate to a pdf file. but every time i try to save the file(loaded document) i get this error (System.OverflowException: 'Array dimensions exceeded supported range.'), please help

GetX509() ' to obtain Cert as x509 Certificate from store under current User
Dim document As New PdfLoadedDocument("a.pdf")
Dim page As PdfLoadedPage = TryCast(document.Pages(0), PdfLoadedPage)

Dim pdfCert As PdfCertificate = New PdfCertificate(cert)
Dim signature As PdfSignature = New PdfSignature(document, page, pdfCert, "Signature")
signature.Reason = "Support X509certificate2"
Dim stream As MemoryStream = New MemoryStream()
document.Save(stream) ' Error: (System.OverflowException: 'Array dimensions exceeded supported range.')
Dim file As FileStream = New FileStream("X509cert.pdf", FileMode.Create, FileAccess.Write)
stream.WriteTo(file)
file.Close()
document.Close()

Loader.
Live Chat Icon For mobile
Up arrow icon