- Home
- Forum
- Console App
- System.OverflowException: Arithmetic operation resulted in an overflow when signing PDF with timestamp
System.OverflowException: Arithmetic operation resulted in an overflow when signing PDF with timestamp
When I try sign a PDF using EnableLtv and TimeStampServer I got the error:
System.OverflowException: Arithmetic operation resulted in an overflow.
at Syncfusion.Pdf.Security.PdfSignatureDictionary.DocumentSaved(Object sender, DocumentSavedEventArgs e)
at Syncfusion.Pdf.PdfDocumentBase.OnDocumentSaved(DocumentSavedEventArgs args)
at Syncfusion.Pdf.Parsing.PdfLoadedDocument.Save(Stream stream)
My code:
What I'm doing wrong?
We tried to replicate the reported behavior with our test document based on the provided details and we are unable to reproduce this issue and we suspect the reported issue occurs with a specific document.
Could you please share the complete code snippet and input pdf document and it will be helpful for our further investigation.
The problem that might happen is when the expected size for the signature content limit exists together with the certificate and adding a time stamp. We ask you to make the expected signature size bigger to fix this issue.
Please make the changes we've highlighted below in your example to solve this problem. If the problem continues, please give us your certificate file and password details so we can look into the issue more deeply on our end..
|
public void Sign(Stream pdfStream, Stream certificateStream, string password) { PdfLoadedDocument document = new PdfLoadedDocument(pdfStream); PdfCertificate certificate = new PdfCertificate(certificateStream, password);
PdfSignature signature = new PdfSignature(document, document.Pages[0], certificate, "Signature"); signature.Settings.CryptographicStandard = CryptographicStandard.CADES; signature.Settings.DigestAlgorithm = DigestAlgorithm.SHA512; signature.EstimatedSignatureSize = 200000; signature.TimeStampServer = new TimeStampServer(new Uri(http://timestamp.digicert.com), "USERNAME", "PASSWORD"); signature.EnableLtv = true;
using (FileStream fileStream = new FileStream("signed.pdf", FileMode.Create, FileAccess.ReadWrite)) { document.Save(fileStream); } //Close the document document.Close(true); } |
- 3 Replies
- 3 Participants
- Marked answer
-
PG Promedico Gestao Hospitalar
- Aug 5, 2023 03:14 PM UTC
- Aug 10, 2023 12:46 PM UTC