Esempio n. 1
0
        /// <summary>
        /// Main method for running the sample.
        /// </summary>
        public static SampleOutputInfo[] Run(Stream formStream, SignatureTimestampNeeded onTimeStamp)
        {
            PDFFixedDocument document = new PDFFixedDocument(formStream);

            PDFSignatureField signField = document.Form.Fields["signhere"] as PDFSignatureField;

            signField.Signature = new PDFDocumentTimeStamp();
            signField.Signature.TimestampDigestAlgorithm    = PDFDigitalSignatureDigestAlgorithm.Sha256;
            signField.Signature.OnSignatureTimestampNeeded += onTimeStamp;

            SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "documenttimestamp.pdf") };
            return(output);
        }
        /// <summary>
        /// Main method for running the sample.
        /// </summary>
        public static SampleOutputInfo[] Run(Stream formStream, X509Certificate2 certificate, SignatureTimestampNeeded onTimeStamp)
        {
            PDFFixedDocument document = new PDFFixedDocument(formStream);

            PDFSignatureField      signField = document.Form.Fields["signhere"] as PDFSignatureField;
            PDFCmsDigitalSignature signature = new PDFCmsDigitalSignature();

            signature.SignatureDigestAlgorithm = PDFDigitalSignatureDigestAlgorithm.Sha256;
            signature.Certificate = certificate;
            signature.ContactInfo = "*****@*****.**";
            signature.Location    = "Cluj Napoca";
            signature.Name        = "O2 Solutions Support";
            signature.Reason      = "Signature with timestamp";
            signature.OnSignatureTimestampNeeded += onTimeStamp;
            signField.Signature = signature;

            SampleOutputInfo[] output = new SampleOutputInfo[] { new SampleOutputInfo(document, "signaturewithtimestamp.pdf") };
            return(output);
        }